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

Side by Side Diff: components/gcm_driver/gcm_driver_desktop.cc

Issue 631343002: [GCM] Fetching OAuth2 tokens periodically in account tracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mapper-in-driver
Patch Set: Cleaning up last CR comments Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/gcm_driver/gcm_driver_desktop.h" 5 #include "components/gcm_driver/gcm_driver_desktop.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 new GCMChannelStatusSyncer(this, 356 new GCMChannelStatusSyncer(this,
357 prefs, 357 prefs,
358 channel_status_request_url, 358 channel_status_request_url,
359 user_agent, 359 user_agent,
360 request_context)), 360 request_context)),
361 signed_in_(false), 361 signed_in_(false),
362 gcm_started_(false), 362 gcm_started_(false),
363 gcm_enabled_(true), 363 gcm_enabled_(true),
364 connected_(false), 364 connected_(false),
365 account_mapper_(new GCMAccountMapper(this)), 365 account_mapper_(new GCMAccountMapper(this)),
366 // Setting to max, to make sure it does not prompt for token reporting
367 // Before reading a reasonable value from the DB, which might be never,
368 // in which case the fetching will be triggered.
369 last_token_fetch_time_(base::Time::Max()),
366 ui_thread_(ui_thread), 370 ui_thread_(ui_thread),
367 io_thread_(io_thread), 371 io_thread_(io_thread),
368 weak_ptr_factory_(this) { 372 weak_ptr_factory_(this) {
369 gcm_enabled_ = gcm_channel_status_syncer_->gcm_enabled(); 373 gcm_enabled_ = gcm_channel_status_syncer_->gcm_enabled();
370 374
371 // Create and initialize the GCMClient. Note that this does not initiate the 375 // Create and initialize the GCMClient. Note that this does not initiate the
372 // GCM check-in. 376 // GCM check-in.
373 io_worker_.reset(new IOWorker(ui_thread, io_thread)); 377 io_worker_.reset(new IOWorker(ui_thread, io_thread));
374 io_thread_->PostTask( 378 io_thread_->PostTask(
375 FROM_HERE, 379 FROM_HERE,
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return; 769 return;
766 770
767 GetAppHandler(app_id)->OnSendAcknowledged(app_id, message_id); 771 GetAppHandler(app_id)->OnSendAcknowledged(app_id, message_id);
768 } 772 }
769 773
770 void GCMDriverDesktop::GCMClientReady( 774 void GCMDriverDesktop::GCMClientReady(
771 const std::vector<AccountMapping>& account_mappings, 775 const std::vector<AccountMapping>& account_mappings,
772 const base::Time& last_token_fetch_time) { 776 const base::Time& last_token_fetch_time) {
773 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 777 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
774 778
779 last_token_fetch_time_ = last_token_fetch_time;
780
775 GCMDriver::AddAppHandler(kGCMAccountMapperAppId, account_mapper_.get()); 781 GCMDriver::AddAppHandler(kGCMAccountMapperAppId, account_mapper_.get());
776 account_mapper_->Initialize(account_mappings); 782 account_mapper_->Initialize(account_mappings);
777 last_token_fetch_time_ = last_token_fetch_time;
778 783
779 delayed_task_controller_->SetReady(); 784 delayed_task_controller_->SetReady();
780 } 785 }
781 786
782 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { 787 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) {
783 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 788 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
784 789
785 connected_ = true; 790 connected_ = true;
786 791
787 // Drop the event if the service has been stopped. 792 // Drop the event if the service has been stopped.
(...skipping 24 matching lines...) Expand all
812 817
813 // Normally request_gcm_statistics_callback_ would not be null. 818 // Normally request_gcm_statistics_callback_ would not be null.
814 if (!request_gcm_statistics_callback_.is_null()) 819 if (!request_gcm_statistics_callback_.is_null())
815 request_gcm_statistics_callback_.Run(stats); 820 request_gcm_statistics_callback_.Run(stats);
816 else 821 else
817 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; 822 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL.";
818 } 823 }
819 824
820 } // namespace gcm 825 } // namespace gcm
821 826
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698