Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: components/gcm_driver/gcm_driver_desktop.cc

Issue 681453004: [GCM] Adding last token fetching time handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Android build Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.h ('k') | google_apis/gcm/engine/gcm_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_driver_desktop.cc
diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc
index fc0c36af2ff0a2c45e781821c92c0f473641734e..6902efbc85e0a91ed49755198fd22a9ac052e9d8 100644
--- a/components/gcm_driver/gcm_driver_desktop.cc
+++ b/components/gcm_driver/gcm_driver_desktop.cc
@@ -51,7 +51,8 @@ class GCMDriverDesktop::IOWorker : public GCMClient::Delegate {
const GCMClient::SendErrorDetails& send_error_details) override;
void OnSendAcknowledged(const std::string& app_id,
const std::string& message_id) override;
- void OnGCMReady(const std::vector<AccountMapping>& account_mappings) override;
+ void OnGCMReady(const std::vector<AccountMapping>& account_mappings,
+ const base::Time& last_token_fetch_time) override;
void OnActivityRecorded() override;
void OnConnected(const net::IPEndPoint& ip_endpoint) override;
void OnDisconnected() override;
@@ -79,6 +80,7 @@ class GCMDriverDesktop::IOWorker : public GCMClient::Delegate {
const std::vector<GCMClient::AccountTokenInfo>& account_tokens);
void UpdateAccountMapping(const AccountMapping& account_mapping);
void RemoveAccountMapping(const std::string& account_id);
+ void SetLastTokenFetchTime(const base::Time& time);
// For testing purpose. Can be called from UI thread. Use with care.
GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); }
@@ -203,11 +205,13 @@ void GCMDriverDesktop::IOWorker::OnSendAcknowledged(
}
void GCMDriverDesktop::IOWorker::OnGCMReady(
- const std::vector<AccountMapping>& account_mappings) {
- ui_thread_->PostTask(
- FROM_HERE,
- base::Bind(
- &GCMDriverDesktop::GCMClientReady, service_, account_mappings));
+ const std::vector<AccountMapping>& account_mappings,
+ const base::Time& last_token_fetch_time) {
+ ui_thread_->PostTask(FROM_HERE,
+ base::Bind(&GCMDriverDesktop::GCMClientReady,
+ service_,
+ account_mappings,
+ last_token_fetch_time));
}
void GCMDriverDesktop::IOWorker::OnActivityRecorded() {
@@ -330,6 +334,13 @@ void GCMDriverDesktop::IOWorker::RemoveAccountMapping(
gcm_client_->RemoveAccountMapping(account_id);
}
+void GCMDriverDesktop::IOWorker::SetLastTokenFetchTime(const base::Time& time) {
+ DCHECK(io_thread_->RunsTasksOnCurrentThread());
+
+ if (gcm_client_.get())
+ gcm_client_->SetLastTokenFetchTime(time);
+}
+
GCMDriverDesktop::GCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
const GCMClient::ChromeBuildInfo& chrome_build_info,
@@ -628,6 +639,20 @@ void GCMDriverDesktop::RemoveAccountMapping(const std::string& account_id) {
account_id));
}
+base::Time GCMDriverDesktop::GetLastTokenFetchTime() {
+ return last_token_fetch_time_;
+}
+
+void GCMDriverDesktop::SetLastTokenFetchTime(const base::Time& time) {
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread());
+
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&GCMDriverDesktop::IOWorker::SetLastTokenFetchTime,
+ base::Unretained(io_worker_.get()),
+ time));
+}
+
void GCMDriverDesktop::SetAccountTokens(
const std::vector<GCMClient::AccountTokenInfo>& account_tokens) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
@@ -743,11 +768,13 @@ void GCMDriverDesktop::SendAcknowledged(const std::string& app_id,
}
void GCMDriverDesktop::GCMClientReady(
- const std::vector<AccountMapping>& account_mappings) {
+ const std::vector<AccountMapping>& account_mappings,
+ const base::Time& last_token_fetch_time) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
GCMDriver::AddAppHandler(kGCMAccountMapperAppId, account_mapper_.get());
account_mapper_->Initialize(account_mappings);
+ last_token_fetch_time_ = last_token_fetch_time;
delayed_task_controller_->SetReady();
}
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.h ('k') | google_apis/gcm/engine/gcm_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698