Android Wifi定位
2010-08-23 01:31:00 来源:WEB开发网如果找不到,再做实际的请求
1 return request_->MakeRequest(access_token,2 radio_data_,3 wifi_data_,4 request_address_,5 address_language_,6 kBadLatLng, // We don't have a position to pass7 kBadLatLng, // to the server.8 timestamp_);
7.客户端协议包装
前面的request_是NetworkLocationRequest实例,先看 MakeRequest的实现:
先对参数进行打包:
1 if (!FormRequestBody(host_name_, access_token, radio_data, wifi_data,2 request_address, address_language, latitude, longitude,3 is_reverse_geocode_, &post_body_)) {4 return false;5 }
通知负责收发的线程
1 thread_event_.Signal();
8.负责收发的线程
1 void NetworkLocationRequest::Run() { 2 while (true) { 3 thread_event_.Wait(); 4 if (is_shutting_down_) { 5 break; 6 } 7 MakeRequestImpl(); 8 } 9 }10 11 void NetworkLocationRequest::MakeRequestImpl() {12 WebCacheDB::PayloadInfo payload;
把打包好的数据通过HTTP请求,发送给服务器
1 scoped_refptr payload_data; 2 bool result = HttpPost(url_.c_str(), 3 false, // Not capturing, so follow redirects 4 NULL, // reason_header_value 5 HttpConstants::kMimeApplicationJson, // Content-Type 6 NULL, // mod_since_date 7 NULL, // required_cookie 8 true, // disable_browser_cookies 9 post_body_.get(),10 &payload,11 &payload_data,12 NULL, // was_redirected13 NULL, // full_redirect_url14 NULL); // error_message15 16 MutexLock lock(&is_processing_response_mutex_);17 // is_aborted_ may be true even if HttpPost succeeded.18 if (is_aborted_) {19
更多精彩
赞助商链接