Hello andreip,
I'd like you to do a code review. Please execute
g4 diff -c 10378334
or point your web browser to
http://mondrian/10378334
to review the following code:
Change 10378334 by stevebl...@steveblock-gears7 on 2009/03/05 11:46:36 *pending*
Provides better definition of 'change of WiFi data' ...
- 50% or more APs change
- 5 or more APs change
where APs are different if their MAC addresses differ.
Also updates configureGeolocationWifiDataProviderForTest to allow
multiple access points to be specified.
R=andreip
[email protected]
DELTA=200 (75 added, 43 deleted, 82 changed)
OCL=10378334
Affected files ...
... //depot/googleclient/gears/opensource/gears/cctests/test.h#32 edit
...
//depot/googleclient/gears/opensource/gears/geolocation/device_data_provider.h#10
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#37
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.h#13
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/network_location_request.cc#33
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc#7
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h#3
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc#13
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h#6
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc#9
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h#5
edit
...
//depot/googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js#18
edit
200 delta lines: 75 added, 43 deleted, 82 changed
Also consider running:
g4 lint -c 10378334
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [email protected].
Change 10378334 by stevebl...@steveblock-gears7 on 2009/03/05 11:46:36 *pending*
Provides better definition of 'change of WiFi data' ...
- 50% or more APs change
- 5 or more APs change
where APs are different if their MAC addresses differ.
Also updates configureGeolocationWifiDataProviderForTest to allow
multiple access points to be specified.
Affected files ...
... //depot/googleclient/gears/opensource/gears/cctests/test.h#32 edit
...
//depot/googleclient/gears/opensource/gears/geolocation/device_data_provider.h#10
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#37
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.h#13
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/network_location_request.cc#33
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc#7
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h#3
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc#13
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h#6
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc#9
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h#5
edit
...
//depot/googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js#18
edit
==== //depot/googleclient/gears/opensource/gears/cctests/test.h#32 -
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/cctests/test.h ====
# action=edit type=text
--- googleclient/gears/opensource/gears/cctests/test.h 2009-03-05
14:59:57.000000000 +0000
+++ googleclient/gears/opensource/gears/cctests/test.h 2009-03-05
14:07:16.000000000 +0000
@@ -168,7 +168,7 @@
// provider and sets the that the mock provider will provide. Note that
// we only support data for one access_point. Fields are mac_address,
// radio_signal_strength, age, channel, signal_to_noise and ssid.
- // IN: object wifi_data
+ // IN: array of access_point_data objects
// OUT: nothing
void ConfigureGeolocationWifiDataProviderForTest(JsCallContext *context);
====
//depot/googleclient/gears/opensource/gears/geolocation/device_data_provider.h#10
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/device_data_provider.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/device_data_provider.h
2009-03-05 11:46:30.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/device_data_provider.h
2009-03-05 14:40:14.000000000 +0000
@@ -121,6 +121,12 @@
radio_type == other.radio_type &&
carrier == other.carrier;
}
+ // Determines whether a new set of radio data differs significantly from
this.
+ bool DiffersSignificantly(const RadioData &other) const {
+ // This is required by MockDeviceDataProviderImpl.
+ // TODO(steveblock): Implement properly.
+ return !Matches(other);
+ }
std::string16 device_id;
std::vector<CellData> cell_data;
@@ -137,11 +143,10 @@
age(kint32min),
channel(kint32min),
signal_to_noise(kint32min) {}
- bool Matches(const AccessPointData &other) const {
- // Ignore radio_signal_strength, age and signal_to_noise when matching.
- return mac_address == other.mac_address &&
- channel == other.channel &&
- ssid == other.ssid;
+ // For use in std::set. Sort by MAC address.
+ bool operator<(const AccessPointData &other) const {
+ // Sort in lexographic order of MAC address.
+ return mac_address < other.mac_address;
}
std::string16 mac_address;
@@ -152,25 +157,37 @@
std::string16 ssid; // Network identifier
};
-static bool AccessPointDataMatches(const AccessPointData &data1,
- const AccessPointData &data2) {
- return data1.Matches(data2);
-}
-
// All data for wifi.
struct WifiData {
- bool Matches(const WifiData &other) const {
- if (access_point_data.size() != other.access_point_data.size()) {
- return false;
- }
- if (!std::equal(access_point_data.begin(), access_point_data.end(),
- other.access_point_data.begin(), AccessPointDataMatches)) {
- return false;
- }
- return true;
- }
-
- std::vector<AccessPointData> access_point_data;
+ // Determines whether a new set of WiFi data differs significantly from this.
+ bool DiffersSignificantly(const WifiData &other) const {
+ // At least 5 or 50% of access points added or removed is significant.
+ static const size_t kMinChangedAccessPoints = 5;
+
+ // Compute size of interesction of old and new sets.
+ size_t num_common = 0;
+ for (AccessPointDataSet::const_iterator iter = access_point_data.begin();
+ iter != access_point_data.end();
+ iter++) {
+ if (other.access_point_data.find(*iter) !=
+ other.access_point_data.end()) {
+ ++num_common;
+ }
+ }
+ assert(num_common <= access_point_data.size());
+ assert(num_common <= other.access_point_data.size());
+
+ // Test how many have changed.
+ size_t added_or_removed = std::max(
+ other.access_point_data.size() - num_common,
+ access_point_data.size() - num_common);
+ return added_or_removed >=
+ std::min(kMinChangedAccessPoints, access_point_data.size() / 2);
+ }
+
+ // Store access points a set for for quick evaluation of intersection.
+ typedef std::set<AccessPointData> AccessPointDataSet;
+ AccessPointDataSet access_point_data;
};
template<typename DataType>
====
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc#37
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
2009-03-05 11:46:31.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/geolocation_test.cc
2009-03-05 14:40:59.000000000 +0000
@@ -120,8 +120,11 @@
static void SetData(const DataType &new_data) {
MutexLock lock(&data_mutex_);
+ bool differs = data_.DiffersSignificantly(new_data);
data_ = new_data;
- event_.Signal();
+ if (differs) {
+ event_.Signal();
+ }
}
private:
@@ -312,7 +315,7 @@
access_point_data.channel = 19;
access_point_data.signal_to_noise = 10;
access_point_data.ssid = STRING16(L"Test SSID");
- wifi_data.access_point_data.push_back(access_point_data);
+ wifi_data.access_point_data.insert(access_point_data);
scoped_refptr<BlobInterface> blob;
if (!NetworkLocationRequest::FormRequestBody(STRING16(L"www.google.com"),
@@ -507,39 +510,50 @@
assert(context);
// Get the arguments provided from JavaScript.
- scoped_ptr<JsObject> object;
+ scoped_ptr<JsArray> js_array;
JsArgument argv[] = {
- { JSPARAM_REQUIRED, JSPARAM_OBJECT, as_out_parameter(object) }
+ { JSPARAM_REQUIRED, JSPARAM_ARRAY, as_out_parameter(js_array) }
};
context->GetArguments(ARRAYSIZE(argv), argv);
if (context->is_exception_set()) {
return;
}
- // Note that we only support providing data for a single access point.
- AccessPointData access_point_data;
- // Update the fields of access_point_data, if they have been provided.
- GetStringPropertyIfDefined(context, object.get(), kMacAddressString,
- &access_point_data.mac_address);
- GetIntegerPropertyIfDefined(context, object.get(),
kRadioSignalStrengthString,
- &access_point_data.radio_signal_strength);
- GetIntegerPropertyIfDefined(context, object.get(), kAgeString,
- &access_point_data.age);
- GetIntegerPropertyIfDefined(context, object.get(), kChannelString,
- &access_point_data.channel);
- GetIntegerPropertyIfDefined(context, object.get(), kSignalToNoiseString,
- &access_point_data.signal_to_noise);
- GetStringPropertyIfDefined(context, object.get(), kSsidString,
- &access_point_data.ssid);
-
- // The GetXXXPropertyIfDefined functions set an exception if the property has
- // the wrong type.
- if (context->is_exception_set()) {
- return;
- }
+ int length = -1;
+ js_array->GetLength(&length);
+ assert(length > -1);
WifiData wifi_data;
- wifi_data.access_point_data.push_back(access_point_data);
+ for (int i = 0; i < length; ++i) {
+ scoped_ptr<JsObject> object;
+ if (!js_array->GetElementAsObject(i, as_out_parameter(object))) {
+ context->SetException(STRING16(L"Parameter must be array of objects."));
+ return;
+ }
+ AccessPointData access_point_data;
+ // Update the fields of access_point_data, if they have been provided.
+ GetStringPropertyIfDefined(context, object.get(), kMacAddressString,
+ &access_point_data.mac_address);
+ GetIntegerPropertyIfDefined(context, object.get(),
+ kRadioSignalStrengthString,
+ &access_point_data.radio_signal_strength);
+ GetIntegerPropertyIfDefined(context, object.get(), kAgeString,
+ &access_point_data.age);
+ GetIntegerPropertyIfDefined(context, object.get(), kChannelString,
+ &access_point_data.channel);
+ GetIntegerPropertyIfDefined(context, object.get(), kSignalToNoiseString,
+ &access_point_data.signal_to_noise);
+ GetStringPropertyIfDefined(context, object.get(), kSsidString,
+ &access_point_data.ssid);
+
+ // The GetXXXPropertyIfDefined functions set an exception if the property
+ // has the wrong type.
+ if (context->is_exception_set()) {
+ return;
+ }
+
+ wifi_data.access_point_data.insert(access_point_data);
+ }
MockDeviceDataProviderImpl<WifiData>::SetData(wifi_data);
WifiDataProvider::SetFactory(MockDeviceDataProviderImpl<WifiData>::Create);
@@ -560,9 +574,9 @@
return;
}
- GetDoublePropertyIfDefined(context, object.get(), STRING16(L"latitude"),
// The GetXXXPropertyIfDefined functions set an exception if the property has
// the wrong type.
+ GetDoublePropertyIfDefined(context, object.get(), STRING16(L"latitude"),
&position->latitude);
GetDoublePropertyIfDefined(context, object.get(), STRING16(L"longitude"),
&position->longitude);
====
//depot/googleclient/gears/opensource/gears/geolocation/geolocation_test.h#13 -
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/geolocation_test.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/geolocation_test.h
2009-03-05 14:59:57.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/geolocation_test.h
2009-03-05 14:06:36.000000000 +0000
@@ -79,27 +79,27 @@
// OUT: nothing
void ConfigureGeolocationRadioDataProviderForTest(JsCallContext *context);
- // Removes the mock radio data provider. After this call, the radio data
- // provider factory will be creating 'real' radio data provider instances
- // again.
- // IN: nothing
- // OUT: nothing
- void RemoveMockRadioDataProvider();
+// Removes the mock radio data provider. After this call, the radio data
+// provider factory will be creating 'real' radio data provider instances
+// again.
+// IN: nothing
+// OUT: nothing
+void RemoveMockRadioDataProvider();
// Configures the wifi data provider factory to use a mock wifi device data
// provider and sets the that the mock provider will provide. Note that
// we only support data for one access_point. Fields are mac_address,
// radio_signal_strength, age, channel, signal_to_noise and ssid.
-// IN: object wifi_data
+// IN: array of access_point_data objects
// OUT: nothing
void ConfigureGeolocationWifiDataProviderForTest(JsCallContext *context);
- // Removes the mock wifi data provider. After this call, the wifi data
- // provider factory will be creating 'real' wifi data provider instances
- // again.
- // IN: nothing
- // OUT: nothing
- void RemoveMockWifiDataProvider();
+// Removes the mock wifi data provider. After this call, the wifi data
+// provider factory will be creating 'real' wifi data provider instances
+// again.
+// IN: nothing
+// OUT: nothing
+void RemoveMockWifiDataProvider();
// Configures the location provider pool to use a mock location provider. Sets
// the position that the mock provider will provide. Properties are latitude,
====
//depot/googleclient/gears/opensource/gears/geolocation/network_location_request.cc#33
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/network_location_request.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/network_location_request.cc
2008-12-23 13:35:34.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/network_location_request.cc
2009-03-05 11:46:47.000000000 +0000
@@ -506,25 +506,25 @@
static void AddWifiData(const WifiData &wifi_data, Json::Value *body_object) {
assert(body_object);
+ if (wifi_data.access_point_data.empty()) {
+ return;
+ }
+
Json::Value wifi_towers;
assert(wifi_towers.isArray());
- int num_wifi_towers = static_cast<int>(wifi_data.access_point_data.size());
- for (int i = 0; i < num_wifi_towers; ++i) {
+ for (WifiData::AccessPointDataSet::const_iterator iter =
+ wifi_data.access_point_data.begin();
+ iter != wifi_data.access_point_data.end();
+ iter++) {
Json::Value wifi_tower;
assert(wifi_tower.isObject());
- AddString("mac_address", wifi_data.access_point_data[i].mac_address,
- &wifi_tower);
- AddInteger("signal_strength",
- wifi_data.access_point_data[i].radio_signal_strength,
- &wifi_tower);
- AddInteger("age", wifi_data.access_point_data[i].age, &wifi_tower);
- AddInteger("channel", wifi_data.access_point_data[i].channel, &wifi_tower);
- AddInteger("signal_to_noise",
- wifi_data.access_point_data[i].signal_to_noise, &wifi_tower);
- AddString("ssid", wifi_data.access_point_data[i].ssid, &wifi_tower);
- wifi_towers[i] = wifi_tower;
- }
- if (num_wifi_towers > 0) {
- (*body_object)["wifi_towers"] = wifi_towers;
- }
-}
+ AddString("mac_address", iter->mac_address, &wifi_tower);
+ AddInteger("signal_strength", iter->radio_signal_strength, &wifi_tower);
+ AddInteger("age", iter->age, &wifi_tower);
+ AddInteger("channel", iter->channel, &wifi_tower);
+ AddInteger("signal_to_noise", iter->signal_to_noise, &wifi_tower);
+ AddString("ssid", iter->ssid, &wifi_tower);
+ wifi_towers.append(wifi_tower);
+ }
+ (*body_object)["wifi_towers"] = wifi_towers;
+}
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc#7
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc
2009-03-05 11:46:31.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_linux.cc
2009-03-05 14:42:38.000000000 +0000
@@ -115,12 +115,11 @@
if (GetAccessPointData(&new_data.access_point_data)) {
bool update_available;
data_mutex_.Lock();
- if (update_available = !wifi_data_.Matches(new_data)) {
- wifi_data_ = new_data;
- is_first_scan_complete_ = true;
- }
+ update_available = wifi_data_.DiffersSignificantly(new_data);
+ wifi_data_ = new_data;
data_mutex_.Unlock();
if (update_available) {
+ is_first_scan_complete_ = true;
NotifyListeners();
}
}
@@ -154,6 +153,8 @@
const std::string &ssid_string,
const std::string &signal_strength_string,
AccessPointData *access_point_data) {
+ // Currently we get only MAC address, SSID and signal strength.
+ // TODO(steveblock): Work out how to get age, channel and signal-to-noise.
std::string::size_type index;
if ((index = line.find(mac_address_string)) != std::string::npos) {
// MAC address
@@ -213,7 +214,7 @@
const std::string &mac_address_string,
const std::string &ssid_string,
const std::string &signal_strength_string,
- std::vector<AccessPointData> *access_points) {
+ WifiData::AccessPointDataSet *access_points) {
// Open pipe in read mode.
FILE *result_pipe = popen(command, "r");
if (result_pipe == NULL) {
@@ -247,14 +248,14 @@
ssid_string,
signal_strength_string,
&access_point_data);
- access_points->push_back(access_point_data);
+ access_points->insert(access_point_data);
start = end;
}
return !access_points->empty();
}
-static bool GetAccessPointData(std::vector<AccessPointData> *access_points) {
+static bool GetAccessPointData(WifiData::AccessPointDataSet *access_points) {
return IssueCommandAndParseResult("iwlist scan 2> /dev/null",
"Cell ",
"Address: ",
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc#5
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc
2009-03-05 11:46:31.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.cc
2009-03-05 14:43:02.000000000 +0000
@@ -98,12 +98,11 @@
GetAccessPointData(&new_data.access_point_data);
bool update_available;
data_mutex_.Lock();
- if (update_available = !wifi_data_.Matches(new_data)) {
- wifi_data_ = new_data;
- is_first_scan_complete_ = true;
- }
+ update_available = wifi_data_.DiffersSignificantly(new_data);
+ wifi_data_ = new_data;
data_mutex_.Unlock();
if (update_available) {
+ is_first_scan_complete_ = true;
NotifyListeners();
}
} while (!stop_event_.WaitWithTimeout(kPollingInterval));
@@ -114,7 +113,7 @@
}
void OsxWifiDataProvider::GetAccessPointData(
- std::vector<AccessPointData> *access_points) {
+ WifiData::AccessPointDataSet *access_points) {
assert(access_points);
assert(WirelessScanSplit_function_);
CFArrayRef managed_access_points = NULL;
@@ -138,6 +137,9 @@
reinterpret_cast<const CFDataRef>(
CFArrayGetValueAtIndex(managed_access_points, i))));
+ // Currently we get only MAC address, signal strength, channel
+ // signal-to-noise and SSID
+ // TODO(steveblock): Work out how to get age.
AccessPointData access_point_data;
access_point_data.mac_address =
MacAddressAsString16(access_point_info->macAddress);
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h#3
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h
2009-03-05 11:46:31.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_osx.h
2009-03-05 11:46:55.000000000 +0000
@@ -47,7 +47,7 @@
// Thread implementation.
virtual void Run();
- void GetAccessPointData(std::vector<AccessPointData> *access_points);
+ void GetAccessPointData(WifiData::AccessPointDataSet *access_points);
// Context and function pointers for Apple80211 library.
WirelessContextPtr wifi_context_;
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc#13
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc
2009-03-05 11:46:31.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.cc
2009-03-05 14:43:24.000000000 +0000
@@ -131,7 +131,7 @@
// Use the WLAN interface if we're on Vista and if it's available. Otherwise,
// use NDIS.
typedef bool (Win32WifiDataProvider::*GetAccessPointDataFunction)(
- std::vector<AccessPointData> *data);
+ WifiData::AccessPointDataSet *data);
GetAccessPointDataFunction get_access_point_data_function = NULL;
if (VistaUtils::IsRunningOnVista() && library) {
GetWLANFunctions(library);
@@ -154,12 +154,11 @@
if ((this->*get_access_point_data_function)(&new_data.access_point_data)) {
bool update_available;
data_mutex_.Lock();
- if (update_available = !wifi_data_.Matches(new_data)) {
- wifi_data_ = new_data;
- is_first_scan_complete_ = true;
- }
+ update_available = wifi_data_.DiffersSignificantly(new_data);
+ wifi_data_ = new_data;
data_mutex_.Unlock();
if (update_available) {
+ is_first_scan_complete_ = true;
NotifyListeners();
}
}
@@ -191,7 +190,7 @@
}
bool Win32WifiDataProvider::GetAccessPointDataWLAN(
- std::vector<AccessPointData> *data) {
+ WifiData::AccessPointDataSet *data) {
assert(data);
// Get the handle to the WLAN API.
@@ -240,7 +239,7 @@
int Win32WifiDataProvider::GetInterfaceDataWLAN(
const HANDLE wlan_handle,
const GUID &interface_id,
- std::vector<AccessPointData> *data) {
+ WifiData::AccessPointDataSet *data) {
assert(data);
// WlanGetNetworkBssList allocates bss_list.
WLAN_BSS_LIST *bss_list;
@@ -259,7 +258,7 @@
AccessPointData access_point_data;
if (GetNetworkData(bss_list->wlanBssEntries[i], &access_point_data)) {
++found;
- data->push_back(access_point_data);
+ data->insert(access_point_data);
}
}
@@ -322,7 +321,7 @@
}
bool Win32WifiDataProvider::GetAccessPointDataNDIS(
- std::vector<AccessPointData> *data) {
+ WifiData::AccessPointDataSet *data) {
assert(data);
for (int i = 0; i < static_cast<int>(interface_service_names_.size()); ++i) {
@@ -351,7 +350,7 @@
bool Win32WifiDataProvider::GetInterfaceDataNDIS(
HANDLE adapter_handle,
- std::vector<AccessPointData> *data) {
+ WifiData::AccessPointDataSet *data) {
assert(data);
BYTE *buffer = reinterpret_cast<BYTE*>(malloc(oid_buffer_size_));
@@ -402,6 +401,7 @@
static bool GetNetworkData(const WLAN_BSS_ENTRY &bss_entry,
AccessPointData *access_point_data) {
+ // Currently we get only MAC address, signal strength and SSID.
assert(access_point_data);
access_point_data->mac_address = MacAddressAsString16(bss_entry.dot11Bssid);
access_point_data->radio_signal_strength = bss_entry.lRssi;
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h#6
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h
2009-03-05 11:46:32.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_win32.h
2009-03-05 11:47:00.000000000 +0000
@@ -50,16 +50,16 @@
// Loads the required functions from the DLL.
void GetWLANFunctions(HINSTANCE wlan_library);
// Gets wifi data for all visible access points.
- bool GetAccessPointDataWLAN(std::vector<AccessPointData> *data);
+ bool GetAccessPointDataWLAN(WifiData::AccessPointDataSet *data);
int GetInterfaceDataWLAN(HANDLE wlan_handle,
const GUID &interface_id,
- std::vector<AccessPointData> *data);
+ WifiData::AccessPointDataSet *data);
// NDIS methods.
bool GetInterfacesNDIS();
- bool GetAccessPointDataNDIS(std::vector<AccessPointData> *data);
+ bool GetAccessPointDataNDIS(WifiData::AccessPointDataSet *data);
bool GetInterfaceDataNDIS(HANDLE adapter_handle,
- std::vector<AccessPointData> *data);
+ WifiData::AccessPointDataSet *data);
// Function pointers for WLAN
WlanOpenHandleFunction WlanOpenHandle_function_;
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc#9
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc
2008-11-10 14:29:58.000000000 +0000
+++ googleclient/gears/opensource/gears/geolocation/wifi_data_provider_wince.cc
2009-03-05 14:43:45.000000000 +0000
@@ -43,7 +43,7 @@
// Local function.
static bool GetAccessPointData(const HANDLE &ndis_handle,
- std::vector<AccessPointData> *access_points);
+ WifiData::AccessPointDataSet *access_points);
// static
template<>
@@ -93,12 +93,11 @@
if (GetAccessPointData(ndis_handle, &new_data.access_point_data)) {
bool update_available;
data_mutex_.Lock();
- if (update_available = !wifi_data_.Matches(new_data)) {
- wifi_data_ = new_data;
- is_first_scan_complete_ = true;
- }
+ update_available = wifi_data_.DiffersSignificantly(new_data);
+ wifi_data_ = new_data;
data_mutex_.Unlock();
if (update_available) {
+ is_first_scan_complete_ = true;
NotifyListeners();
}
}
@@ -161,7 +160,7 @@
// supplied vector. Returns the number of access points found, or -1 on
failure.
static int GetCardAccessPointData(const HANDLE &ndis_handle,
const std::string16 &card_name,
- std::vector<AccessPointData> *access_points)
{
+ WifiData::AccessPointDataSet *access_points)
{
assert(access_points);
// Make an OID query to get the list of wifi Basic Service Set (BSS) IDs.
//
@@ -189,7 +188,7 @@
}
static bool GetAccessPointData(const HANDLE &ndis_handle,
- std::vector<AccessPointData> *access_points) {
+ WifiData::AccessPointDataSet *access_points) {
assert(access_points);
// Get the list of adapters. First determine the buffer size.
ULONG buffer_size = 0;
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc#5
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc
====
# action=edit type=text
---
googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc
2009-03-05 11:46:32.000000000 +0000
+++
googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.cc
2009-03-05 11:47:02.000000000 +0000
@@ -34,6 +34,8 @@
bool ConvertToGearsFormat(const NDIS_WLAN_BSSID &data,
AccessPointData *access_point_data) {
+ // Currently we get only MAC address, signal strength and SSID.
+ // TODO(steveblock): Work out how to get age, channel and signal-to-noise.
assert(access_point_data);
access_point_data->mac_address = MacAddressAsString16(data.MacAddress);
access_point_data->radio_signal_strength = data.Rssi;
@@ -41,15 +43,12 @@
UTF8ToString16(reinterpret_cast<const char*>(data.Ssid.Ssid),
data.Ssid.SsidLength,
&access_point_data->ssid);
- // It appears that we can not get the age of the scan. The only way to get
- // this information would be to perform the scan ourselves, which is not
- // possible.
return true;
}
int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST &bss_id_list,
int list_size,
- std::vector<AccessPointData> *data) {
+ WifiData::AccessPointDataSet *data) {
// Walk through the BSS IDs.
int found = 0;
const uint8 *iterator = reinterpret_cast<const
uint8*>(&bss_id_list.Bssid[0]);
@@ -65,7 +64,7 @@
}
AccessPointData access_point_data;
if (ConvertToGearsFormat(*bss_id, &access_point_data)) {
- data->push_back(access_point_data);
+ data->insert(access_point_data);
++found;
}
// Move to the next BSS ID.
====
//depot/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h#5
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h
====
# action=edit type=text
---
googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h
2009-03-05 11:46:32.000000000 +0000
+++
googleclient/gears/opensource/gears/geolocation/wifi_data_provider_windows_common.h
2009-03-05 11:47:05.000000000 +0000
@@ -32,14 +32,14 @@
#include <windows.h>
#include <ntddndis.h>
#include <vector>
+#include "gears/geolocation/device_data_provider.h"
-struct AccessPointData;
// Extracts access point data from the NDIS_802_11_BSSID_LIST structure and
// appends it to the data vector. Returns the number of access points for which
// data was extracted.
int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST &bss_id_list,
int list_size,
- std::vector<AccessPointData> *data);
+ WifiData::AccessPointDataSet *data);
#endif // GEARS_GEOLOCATION_WIFI_DATA_PROVIDER_WINDOWS_COMMON_H__
====
//depot/googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js#18
-
c:\MyDocs\Gears7/googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js
====
# action=edit type=text
---
googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js
2009-03-05 14:59:57.000000000 +0000
+++
googleclient/gears/opensource/gears/test/testcases/internal_geolocation_tests.js
2009-03-05 14:04:35.000000000 +0000
@@ -331,7 +331,7 @@
function makeSuccessfulRequest() {
internalTests.configureGeolocationWifiDataProviderForTest(
- {mac_address: 'good_mac_address'});
+ [{mac_address: 'good_mac_address'}]);
geolocation.getCurrentPosition(
successCallback,
function(error) {
@@ -345,7 +345,7 @@
function makeUnsuccessfulRequest() {
internalTests.configureGeolocationWifiDataProviderForTest(
- {mac_address: 'no_location_mac_address'});
+ [{mac_address: 'no_location_mac_address'}]);
geolocation.getCurrentPosition(
function(position) {
assert(false, 'makeUnsuccessfulRequest succeeded: (' +
@@ -357,7 +357,7 @@
function makeMalformedRequest() {
internalTests.configureGeolocationWifiDataProviderForTest(
- {mac_address: '00-00-00-00-00-00'});
+ [{mac_address: '00-00-00-00-00-00'}]);
internalTests.configureGeolocationRadioDataProviderForTest({cell_id:
88});
geolocation.getCurrentPosition(
function(position) {