summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 14:58:41 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 14:58:41 +0000
commitee8829a058616ab519740edeec6fd1eaf41e748f (patch)
tree437d9da2f64a19bbdfa9e7d8a6c6cac282e0e485 /chrome
parentfacf2f049458b5875398cf26cd78a59365484911 (diff)
downloadchromium_src-ee8829a058616ab519740edeec6fd1eaf41e748f.zip
chromium_src-ee8829a058616ab519740edeec6fd1eaf41e748f.tar.gz
chromium_src-ee8829a058616ab519740edeec6fd1eaf41e748f.tar.bz2
Switch from using custom time / epoch handling code (inherited from gears) to base::Time
BUG=http://code.google.com/p/chromium/issues/detail?id=37510 TEST=unit_tests --gtest_filter=geol* Review URL: http://codereview.chromium.org/776001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/geolocation/device_data_provider.h6
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc2
-rw-r--r--chrome/browser/geolocation/location_arbitrator_unittest.cc2
-rw-r--r--chrome/browser/geolocation/mock_location_provider.cc2
-rw-r--r--chrome/browser/geolocation/network_location_provider.cc14
-rw-r--r--chrome/browser/geolocation/network_location_provider.h4
-rw-r--r--chrome/browser/geolocation/network_location_provider_unittest.cc21
-rw-r--r--chrome/browser/geolocation/network_location_request.cc49
-rw-r--r--chrome/browser/geolocation/network_location_request.h4
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_common_unittest.cc2
-rw-r--r--chrome/common/common_param_traits.cc10
-rw-r--r--chrome/common/common_param_traits_unittest.cc2
-rw-r--r--chrome/common/geoposition.cc3
-rw-r--r--chrome/common/geoposition.h3
-rw-r--r--chrome/renderer/geolocation_dispatcher.cc2
-rw-r--r--chrome/renderer/geolocation_dispatcher.h2
16 files changed, 71 insertions, 57 deletions
diff --git a/chrome/browser/geolocation/device_data_provider.h b/chrome/browser/geolocation/device_data_provider.h
index c70a777..2ed54ea 100644
--- a/chrome/browser/geolocation/device_data_provider.h
+++ b/chrome/browser/geolocation/device_data_provider.h
@@ -50,11 +50,10 @@ struct CellData {
location_area_code(kint32min),
mobile_network_code(kint32min),
mobile_country_code(kint32min),
- age(kint32min),
radio_signal_strength(kint32min),
timing_advance(kint32min) {}
bool Matches(const CellData &other) const {
- // Ignore age and radio_signal_strength when matching.
+ // Ignore radio_signal_strength when matching.
return cell_id == other.cell_id &&
location_area_code == other.location_area_code &&
mobile_network_code == other.mobile_network_code &&
@@ -66,7 +65,6 @@ struct CellData {
int location_area_code; // For current location area
int mobile_network_code; // For current cell
int mobile_country_code; // For current cell
- int age; // Milliseconds since this cell was primary
int radio_signal_strength; // Measured in dBm.
int timing_advance; // Timing advance representing the distance from
// the cell tower. Each unit is roughly 550
@@ -123,13 +121,11 @@ struct RadioData {
struct AccessPointData {
AccessPointData()
: radio_signal_strength(kint32min),
- age(kint32min),
channel(kint32min),
signal_to_noise(kint32min) {}
// MAC address, formatted as per MacAddressAsString16.
string16 mac_address;
int radio_signal_strength; // Measured in dBm
- int age; // Milliseconds since this access point was detected
int channel;
int signal_to_noise; // Ratio in dB
string16 ssid; // Network identifier
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index b2f0656..13b0e0a 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -205,7 +205,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
geoposition.longitude = longitude;
geoposition.accuracy = 0;
geoposition.error_code = Geoposition::ERROR_CODE_NONE;
- geoposition.timestamp = 0;
+ geoposition.timestamp = base::Time::FromDoubleT(0.0);
EXPECT_TRUE(geoposition.IsValidFix());
return geoposition;
}
diff --git a/chrome/browser/geolocation/location_arbitrator_unittest.cc b/chrome/browser/geolocation/location_arbitrator_unittest.cc
index a385f13..6f3bf72 100644
--- a/chrome/browser/geolocation/location_arbitrator_unittest.cc
+++ b/chrome/browser/geolocation/location_arbitrator_unittest.cc
@@ -32,7 +32,7 @@ void SetReferencePosition(Geoposition* position) {
position->latitude = 51.0;
position->longitude = -0.1;
position->accuracy = 400;
- position->timestamp = 87654321;
+ position->timestamp = base::Time::FromDoubleT(87654321.0);
ASSERT_TRUE(position->IsInitialized());
ASSERT_TRUE(position->IsValidFix());
}
diff --git a/chrome/browser/geolocation/mock_location_provider.cc b/chrome/browser/geolocation/mock_location_provider.cc
index 4c817cb..7851f30 100644
--- a/chrome/browser/geolocation/mock_location_provider.cc
+++ b/chrome/browser/geolocation/mock_location_provider.cc
@@ -44,7 +44,7 @@ class AutoMockLocationProvider : public MockLocationProvider {
position_.accuracy = 3;
position_.latitude = 4.3;
position_.longitude = -7.8;
- position_.timestamp = 4567;
+ position_.timestamp = base::Time::FromDoubleT(4567.8);
} else {
position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
}
diff --git a/chrome/browser/geolocation/network_location_provider.cc b/chrome/browser/geolocation/network_location_provider.cc
index 24e2a84..e737e88 100644
--- a/chrome/browser/geolocation/network_location_provider.cc
+++ b/chrome/browser/geolocation/network_location_provider.cc
@@ -15,11 +15,6 @@ const int kDataCompleteWaitPeriod = 1000 * 2; // 2 seconds
// The maximum size of the cache of positions for previously requested device
// data.
const size_t kMaximumCacheSize = 10;
-
-// TODO(joth): Share, or remove usage by porting callers to Time et al.
-int64 GetCurrentTimeMillis() {
- return static_cast<int64>(base::Time::Now().ToDoubleT() * 1000);
-}
} // namespace
// The PositionCache handles caching and retrieving a position returned by a
@@ -98,7 +93,7 @@ class NetworkLocationProvider::PositionCache {
// timestamp of the position.
typedef std::map<string16, Geoposition> CacheMap;
CacheMap cache_;
- typedef std::map<int64, CacheMap::iterator> CacheTimesMap;
+ typedef std::map<base::Time, CacheMap::iterator> CacheTimesMap;
CacheTimesMap cache_times_;
};
@@ -125,7 +120,6 @@ NetworkLocationProvider::NetworkLocationProvider(
wifi_data_provider_(NULL),
is_radio_data_complete_(false),
is_wifi_data_complete_(false),
- device_data_updated_timestamp_(kint64min),
access_token_(access_token),
is_new_data_available_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(delayed_start_task_(this)) {
@@ -227,8 +221,8 @@ void NetworkLocationProvider::RequestPosition() {
delayed_start_task_.RevokeAll();
const Geoposition* cached_position;
cached_position = position_cache_->FindPosition(radio_data_, wifi_data_);
- DCHECK_NE(device_data_updated_timestamp_, kint64min) <<
- "Timestamp must be set before looking up position";
+ DCHECK(!device_data_updated_timestamp_.is_null()) <<
+ "Timestamp must be set before looking up position";
if (cached_position) {
DCHECK(cached_position->IsValidFix());
// Record the position and update its timestamp.
@@ -260,7 +254,7 @@ void NetworkLocationProvider::RequestPosition() {
void NetworkLocationProvider::OnDeviceDataUpdated() {
DCHECK(CalledOnValidThread());
- device_data_updated_timestamp_ = GetCurrentTimeMillis();
+ device_data_updated_timestamp_ = base::Time::Now();
is_new_data_available_ = is_radio_data_complete_ || is_wifi_data_complete_;
if (delayed_start_task_.empty() ||
diff --git a/chrome/browser/geolocation/network_location_provider.h b/chrome/browser/geolocation/network_location_provider.h
index ac6e88a..93072fa 100644
--- a/chrome/browser/geolocation/network_location_provider.h
+++ b/chrome/browser/geolocation/network_location_provider.h
@@ -67,8 +67,10 @@ class NetworkLocationProvider
bool is_wifi_data_complete_;
// The timestamp for the latest device data update.
- int64 device_data_updated_timestamp_;
+ base::Time device_data_updated_timestamp_;
+ // Cached value loaded from the token store or set by a previous server
+ // response, and sent in each subsequent network request.
string16 access_token_;
// The current best position estimate.
diff --git a/chrome/browser/geolocation/network_location_provider_unittest.cc b/chrome/browser/geolocation/network_location_provider_unittest.cc
index b14da95..061eaf7 100644
--- a/chrome/browser/geolocation/network_location_provider_unittest.cc
+++ b/chrome/browser/geolocation/network_location_provider_unittest.cc
@@ -153,7 +153,6 @@ class GeolocationNetworkProviderTest : public testing::Test {
}
static int IndexToChannal(int index) { return index + 4; }
- static int IndexToAge(int index) { return (index * 3) + 100; }
// Creates wifi data containing the specified number of access points, with
// some differentiating charactistics in each.
@@ -163,7 +162,6 @@ class GeolocationNetworkProviderTest : public testing::Test {
AccessPointData ap;
ap.mac_address = ASCIIToUTF16(StringPrintf("%02d-34-56-78-54-32", i));
ap.radio_signal_strength = i;
- ap.age = IndexToAge(i);
ap.channel = IndexToChannal(i);
ap.signal_to_noise = i + 42;
ap.ssid = ASCIIToUTF16("Some nice network");
@@ -174,8 +172,9 @@ class GeolocationNetworkProviderTest : public testing::Test {
static void ParseRequest(const std::string& request_data,
WifiData* wifi_data_out,
+ int* max_age_out,
std::string* access_token_out) {
- CHECK(wifi_data_out && access_token_out);
+ CHECK(wifi_data_out && max_age_out && access_token_out);
scoped_ptr<Value> value(base::JSONReader::Read(request_data, false));
EXPECT_TRUE(value != NULL);
EXPECT_EQ(Value::TYPE_DICTIONARY, value->GetType());
@@ -187,6 +186,7 @@ class GeolocationNetworkProviderTest : public testing::Test {
EXPECT_EQ(attr_value, kTestHost);
// Everything else is optional.
ListValue* wifi_aps;
+ *max_age_out = kint32min;
if (dictionary->GetList(L"wifi_towers", &wifi_aps)) {
int i = 0;
for (ListValue::const_iterator it = wifi_aps->begin();
@@ -196,7 +196,10 @@ class GeolocationNetworkProviderTest : public testing::Test {
AccessPointData data;
ap->GetStringAsUTF16(L"mac_address", &data.mac_address);
ap->GetInteger(L"signal_strength", &data.radio_signal_strength);
- ap->GetInteger(L"age", &data.age);
+ int age = kint32min;
+ ap->GetInteger(L"age", &age);
+ if (age > *max_age_out)
+ *max_age_out = age;
ap->GetInteger(L"channel", &data.channel);
ap->GetInteger(L"signal_to_noise", &data.signal_to_noise);
ap->GetStringAsUTF16(L"ssid", &data.ssid);
@@ -212,7 +215,9 @@ class GeolocationNetworkProviderTest : public testing::Test {
static void CheckEmptyRequestIsValid(const std::string& request_data) {
WifiData wifi_aps;
std::string access_token;
- ParseRequest(request_data, &wifi_aps, &access_token);
+ int max_age;
+ ParseRequest(request_data, &wifi_aps, &max_age, &access_token);
+ EXPECT_EQ(kint32min, max_age);
EXPECT_EQ(0, static_cast<int>(wifi_aps.access_point_data.size()));
EXPECT_TRUE(access_token.empty());
}
@@ -222,7 +227,10 @@ class GeolocationNetworkProviderTest : public testing::Test {
const std::string& expected_access_token) {
WifiData wifi_aps;
std::string access_token;
- ParseRequest(request_data, &wifi_aps, &access_token);
+ int max_age;
+ ParseRequest(request_data, &wifi_aps, &max_age, &access_token);
+ EXPECT_GE(max_age, 0) << "Age must not be negative.";
+ EXPECT_LT(max_age, 10 * 1000) << "This test really shouldn't take 10s.";
EXPECT_EQ(expected_wifi_aps,
static_cast<int>(wifi_aps.access_point_data.size()));
WifiData expected_data = CreateReferenceWifiScanData(expected_wifi_aps);
@@ -234,7 +242,6 @@ class GeolocationNetworkProviderTest : public testing::Test {
EXPECT_EQ(expected->mac_address, actual->mac_address) << i;
EXPECT_EQ(expected->radio_signal_strength, actual->radio_signal_strength)
<< i;
- EXPECT_EQ(expected->age, actual->age) << i;
EXPECT_EQ(expected->channel, actual->channel) << i;
EXPECT_EQ(expected->signal_to_noise, actual->signal_to_noise) << i;
EXPECT_EQ(expected->ssid, actual->ssid) << i;
diff --git a/chrome/browser/geolocation/network_location_request.cc b/chrome/browser/geolocation/network_location_request.cc
index a22a64c..a2961c9 100644
--- a/chrome/browser/geolocation/network_location_request.cc
+++ b/chrome/browser/geolocation/network_location_request.cc
@@ -33,12 +33,13 @@ bool FormRequestBody(const string16& host_name,
const string16& access_token,
const RadioData& radio_data,
const WifiData& wifi_data,
+ const base::Time& timestamp,
std::string* data);
// Parsers the server response.
void GetLocationFromResponse(bool http_post_result,
int status_code,
const std::string& response_body,
- int64 timestamp,
+ const base::Time& timestamp,
const GURL& server_url,
Geoposition* position,
string16* access_token);
@@ -54,11 +55,15 @@ void AddInteger(const std::wstring& property_name,
DictionaryValue* object);
// Parses the server response body. Returns true if parsing was successful.
bool ParseServerResponse(const std::string& response_body,
- int64 timestamp,
+ const base::Time& timestamp,
Geoposition* position,
string16* access_token);
-void AddRadioData(const RadioData& radio_data, DictionaryValue* body_object);
-void AddWifiData(const WifiData& wifi_data, DictionaryValue* body_object);
+void AddRadioData(const RadioData& radio_data,
+ int age_milliseconds,
+ DictionaryValue* body_object);
+void AddWifiData(const WifiData& wifi_data,
+ int age_milliseconds,
+ DictionaryValue* body_object);
} // namespace
int NetworkLocationRequest::url_fetcher_id_for_tests = 0;
@@ -67,7 +72,7 @@ NetworkLocationRequest::NetworkLocationRequest(URLRequestContextGetter* context,
const GURL& url,
const string16& host_name,
ListenerInterface* listener)
- : url_context_(context), timestamp_(kint64min), listener_(listener),
+ : url_context_(context), listener_(listener),
url_(url), host_name_(host_name) {
DCHECK(listener);
}
@@ -78,14 +83,14 @@ NetworkLocationRequest::~NetworkLocationRequest() {
bool NetworkLocationRequest::MakeRequest(const string16& access_token,
const RadioData& radio_data,
const WifiData& wifi_data,
- int64 timestamp) {
+ const base::Time& timestamp) {
if (url_fetcher_ != NULL) {
DLOG(INFO) << "NetworkLocationRequest : Cancelling pending request";
url_fetcher_.reset();
}
std::string post_body;
if (!FormRequestBody(host_name_, access_token, radio_data, wifi_data,
- &post_body)) {
+ timestamp, &post_body)) {
return false;
}
timestamp_ = timestamp;
@@ -132,6 +137,7 @@ bool FormRequestBody(const string16& host_name,
const string16& access_token,
const RadioData& radio_data,
const WifiData& wifi_data,
+ const base::Time& timestamp,
std::string* data) {
DCHECK(data);
@@ -147,8 +153,15 @@ bool FormRequestBody(const string16& host_name,
body_object.SetBoolean(L"request_address", false);
- AddRadioData(radio_data, &body_object);
- AddWifiData(wifi_data, &body_object);
+ int age = kint32min; // Invalid so AddInteger() will ignore.
+ if (!timestamp.is_null()) {
+ // Convert absolute timestamps into a relative age.
+ int64 delta_ms = (base::Time::Now() - timestamp).InMilliseconds();
+ if (delta_ms >= 0 && delta_ms < kint32max)
+ age = static_cast<int>(delta_ms);
+ }
+ AddRadioData(radio_data, age, &body_object);
+ AddWifiData(wifi_data, age, &body_object);
base::JSONWriter::Write(&body_object, false, data);
DLOG(INFO) << "NetworkLocationRequest::FormRequestBody(): Formed body "
@@ -172,7 +185,7 @@ void FormatPositionError(const GURL& server_url,
void GetLocationFromResponse(bool http_post_result,
int status_code,
const std::string& response_body,
- int64 timestamp,
+ const base::Time& timestamp,
const GURL& server_url,
Geoposition* position,
string16* access_token) {
@@ -262,12 +275,12 @@ bool GetAsDouble(const DictionaryValue& object,
}
bool ParseServerResponse(const std::string& response_body,
- int64 timestamp,
+ const base::Time& timestamp,
Geoposition* position,
string16* access_token) {
DCHECK(position);
DCHECK(access_token);
- DCHECK(timestamp != kint64min);
+ DCHECK(!timestamp.is_null());
if (response_body.empty()) {
LOG(WARNING) << "ParseServerResponse() : Response was empty.\n";
@@ -339,7 +352,9 @@ bool ParseServerResponse(const std::string& response_body,
return true;
}
-void AddRadioData(const RadioData& radio_data, DictionaryValue* body_object) {
+void AddRadioData(const RadioData& radio_data,
+ int age_milliseconds,
+ DictionaryValue* body_object) {
DCHECK(body_object);
AddInteger(L"home_mobile_country_code", radio_data.home_mobile_country_code,
@@ -365,7 +380,7 @@ void AddRadioData(const RadioData& radio_data, DictionaryValue* body_object) {
radio_data.cell_data[i].mobile_country_code, cell_tower);
AddInteger(L"mobile_network_code",
radio_data.cell_data[i].mobile_network_code, cell_tower);
- AddInteger(L"age", radio_data.cell_data[i].age, cell_tower);
+ AddInteger(L"age", age_milliseconds, cell_tower);
AddInteger(L"signal_strength",
radio_data.cell_data[i].radio_signal_strength, cell_tower);
AddInteger(L"timing_advance", radio_data.cell_data[i].timing_advance,
@@ -375,7 +390,9 @@ void AddRadioData(const RadioData& radio_data, DictionaryValue* body_object) {
body_object->Set(L"cell_towers", cell_towers);
}
-void AddWifiData(const WifiData& wifi_data, DictionaryValue* body_object) {
+void AddWifiData(const WifiData& wifi_data,
+ int age_milliseconds,
+ DictionaryValue* body_object) {
DCHECK(body_object);
if (wifi_data.access_point_data.empty()) {
@@ -390,7 +407,7 @@ void AddWifiData(const WifiData& wifi_data, DictionaryValue* body_object) {
DictionaryValue* wifi_tower = new DictionaryValue;
AddString(L"mac_address", iter->mac_address, wifi_tower);
AddInteger(L"signal_strength", iter->radio_signal_strength, wifi_tower);
- AddInteger(L"age", iter->age, wifi_tower);
+ AddInteger(L"age", age_milliseconds, wifi_tower);
AddInteger(L"channel", iter->channel, wifi_tower);
AddInteger(L"signal_to_noise", iter->signal_to_noise, wifi_tower);
AddString(L"ssid", iter->ssid, wifi_tower);
diff --git a/chrome/browser/geolocation/network_location_request.h b/chrome/browser/geolocation/network_location_request.h
index 35aa245..7f1b399 100644
--- a/chrome/browser/geolocation/network_location_request.h
+++ b/chrome/browser/geolocation/network_location_request.h
@@ -51,7 +51,7 @@ class NetworkLocationRequest : private URLFetcher::Delegate {
bool MakeRequest(const string16& access_token,
const RadioData& radio_data,
const WifiData& wifi_data,
- int64 timestamp);
+ const base::Time& timestamp);
bool is_request_pending() const { return url_fetcher_ != NULL; }
const GURL& url() const { return url_; }
@@ -66,7 +66,7 @@ class NetworkLocationRequest : private URLFetcher::Delegate {
const std::string& data);
scoped_refptr<URLRequestContextGetter> url_context_;
- int64 timestamp_; // The timestamp of the data used to make the request.
+ base::Time timestamp_; // The timestamp of the data used to make the request.
ListenerInterface* listener_;
const GURL url_;
string16 host_name_;
diff --git a/chrome/browser/geolocation/wifi_data_provider_common_unittest.cc b/chrome/browser/geolocation/wifi_data_provider_common_unittest.cc
index 655fac9..239e583c6 100644
--- a/chrome/browser/geolocation/wifi_data_provider_common_unittest.cc
+++ b/chrome/browser/geolocation/wifi_data_provider_common_unittest.cc
@@ -119,7 +119,6 @@ TEST_F(GeolocationWifiDataProviderCommonTest, DoScanWithResults) {
MessageLoopQuitListener quit_listener(&main_message_loop_);
provider_->AddListener(&quit_listener);
AccessPointData single_access_point;
- single_access_point.age = 1;
single_access_point.channel = 2;
single_access_point.mac_address = 3;
single_access_point.radio_signal_strength = 4;
@@ -133,7 +132,6 @@ TEST_F(GeolocationWifiDataProviderCommonTest, DoScanWithResults) {
WifiData data;
EXPECT_TRUE(provider_->GetData(&data));
EXPECT_EQ(1, static_cast<int>(data.access_point_data.size()));
- EXPECT_EQ(single_access_point.age, data.access_point_data.begin()->age);
EXPECT_EQ(single_access_point.ssid, data.access_point_data.begin()->ssid);
provider_->RemoveListener(&quit_listener);
}
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 7cb9c8a..4995b46 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -293,13 +293,13 @@ void ParamTraits<Geoposition>::Log(const Geoposition& p, std::wstring* l) {
StringPrintf(
L"<Geoposition>"
L"%.6f %.6f %.6f %.6f "
- L"%.6f %.6f %.6f "
- L"%lld ",
+ L"%.6f %.6f %.6f ",
p.latitude, p.longitude, p.accuracy, p.altitude,
- p.altitude_accuracy, p.speed, p.heading,
- p.timestamp));
+ p.altitude_accuracy, p.speed, p.heading));
+ LogParam(p.timestamp, l);
+ l->append(L" ");
l->append(p.error_message);
- LogParam<Geoposition::ErrorCode>(p.error_code, l);
+ LogParam(p.error_code, l);
}
} // namespace IPC
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index d888084..0aac83a 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -176,7 +176,7 @@ TEST(IPCMessageTest, Geoposition) {
input.altitude_accuracy = 9.3;
input.speed = 55;
input.heading = 120;
- input.timestamp = 1977;
+ input.timestamp = base::Time::FromInternalValue(1977);
input.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
input.error_message = L"unittest error message for geoposition";
diff --git a/chrome/common/geoposition.cc b/chrome/common/geoposition.cc
index d4989ed..f8f087c 100644
--- a/chrome/common/geoposition.cc
+++ b/chrome/common/geoposition.cc
@@ -25,7 +25,6 @@ Geoposition::Geoposition()
altitude_accuracy(kBadAccuracy),
heading(kBadHeading),
speed(kBadSpeed),
- timestamp(kBadTimestamp),
error_code(ERROR_CODE_NONE) {
}
@@ -55,7 +54,7 @@ bool Geoposition::is_valid_speed() const {
}
bool Geoposition::is_valid_timestamp() const {
- return timestamp != kBadTimestamp;
+ return !timestamp.is_null();
}
bool Geoposition::IsValidFix() const {
diff --git a/chrome/common/geoposition.h b/chrome/common/geoposition.h
index 94c1dc9..377e7f3 100644
--- a/chrome/common/geoposition.h
+++ b/chrome/common/geoposition.h
@@ -10,6 +10,7 @@
#define CHROME_COMMON_GEOPOSITION_H_
#include "base/string16.h"
+#include "base/time.h"
// The internal representation of a geo position. Some properties use different
// types when passed to JavaScript.
@@ -51,7 +52,7 @@ struct Geoposition {
double altitude_accuracy; // In metres
double heading; // In degrees clockwise relative to the true north
double speed; // In meters per second
- int64 timestamp; // Milliseconds since 1st Jan 1970
+ base::Time timestamp;
// These properties are returned to JavaScript as a PositionError object.
ErrorCode error_code;
diff --git a/chrome/renderer/geolocation_dispatcher.cc b/chrome/renderer/geolocation_dispatcher.cc
index 99c056c..7de2847 100644
--- a/chrome/renderer/geolocation_dispatcher.cc
+++ b/chrome/renderer/geolocation_dispatcher.cc
@@ -97,7 +97,7 @@ void GeolocationDispatcher::OnGeolocationPositionUpdated(
geoposition.is_valid_altitude_accuracy(), geoposition.altitude_accuracy,
geoposition.is_valid_heading(), geoposition.heading,
geoposition.is_valid_speed(), geoposition.speed,
- geoposition.timestamp);
+ static_cast<int64>(geoposition.timestamp.ToDoubleT() * 1000));
}
}
diff --git a/chrome/renderer/geolocation_dispatcher.h b/chrome/renderer/geolocation_dispatcher.h
index 9a3466c..d2a7140 100644
--- a/chrome/renderer/geolocation_dispatcher.h
+++ b/chrome/renderer/geolocation_dispatcher.h
@@ -7,13 +7,13 @@
#include "base/basictypes.h"
#include "base/id_map.h"
-#include "chrome/common/geoposition.h"
#include "ipc/ipc_message.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/GeolocationServiceBridgeChromium.h"
class GURL;
class RenderView;
+struct Geoposition;
// GeolocationDispatcher is a delegate for Geolocation messages used by
// WebKit.