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

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

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 unified diff | Download patch
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_client_impl.h" 5 #include "components/gcm_driver/gcm_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/location.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/stl_util.h" 15 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/thread_task_runner_handle.h"
17 #include "base/time/default_clock.h" 19 #include "base/time/default_clock.h"
18 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
19 #include "components/gcm_driver/gcm_account_mapper.h" 21 #include "components/gcm_driver/gcm_account_mapper.h"
20 #include "components/gcm_driver/gcm_backoff_policy.h" 22 #include "components/gcm_driver/gcm_backoff_policy.h"
21 #include "google_apis/gcm/base/encryptor.h" 23 #include "google_apis/gcm/base/encryptor.h"
22 #include "google_apis/gcm/base/mcs_message.h" 24 #include "google_apis/gcm/base/mcs_message.h"
23 #include "google_apis/gcm/base/mcs_util.h" 25 #include "google_apis/gcm/base/mcs_util.h"
24 #include "google_apis/gcm/engine/checkin_request.h" 26 #include "google_apis/gcm/engine/checkin_request.h"
25 #include "google_apis/gcm/engine/connection_factory_impl.h" 27 #include "google_apis/gcm/engine/connection_factory_impl.h"
26 #include "google_apis/gcm/engine/gcm_registration_request_handler.h" 28 #include "google_apis/gcm/engine/gcm_registration_request_handler.h"
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return; 714 return;
713 715
714 // There should be only one periodic checkin pending at a time. Removing 716 // There should be only one periodic checkin pending at a time. Removing
715 // pending periodic checkin to schedule a new one. 717 // pending periodic checkin to schedule a new one.
716 periodic_checkin_ptr_factory_.InvalidateWeakPtrs(); 718 periodic_checkin_ptr_factory_.InvalidateWeakPtrs();
717 719
718 base::TimeDelta time_to_next_checkin = GetTimeToNextCheckin(); 720 base::TimeDelta time_to_next_checkin = GetTimeToNextCheckin();
719 if (time_to_next_checkin < base::TimeDelta()) 721 if (time_to_next_checkin < base::TimeDelta())
720 time_to_next_checkin = base::TimeDelta(); 722 time_to_next_checkin = base::TimeDelta();
721 723
722 base::MessageLoop::current()->PostDelayedTask( 724 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
723 FROM_HERE, 725 FROM_HERE, base::Bind(&GCMClientImpl::StartCheckin,
724 base::Bind(&GCMClientImpl::StartCheckin, 726 periodic_checkin_ptr_factory_.GetWeakPtr()),
725 periodic_checkin_ptr_factory_.GetWeakPtr()),
726 time_to_next_checkin); 727 time_to_next_checkin);
727 } 728 }
728 729
729 base::TimeDelta GCMClientImpl::GetTimeToNextCheckin() const { 730 base::TimeDelta GCMClientImpl::GetTimeToNextCheckin() const {
730 return last_checkin_time_ + gservices_settings_.GetCheckinInterval() - 731 return last_checkin_time_ + gservices_settings_.GetCheckinInterval() -
731 clock_->Now(); 732 clock_->Now();
732 } 733 }
733 734
734 void GCMClientImpl::SetLastCheckinInfoCallback(bool success) { 735 void GCMClientImpl::SetLastCheckinInfoCallback(bool success) {
735 // TODO(fgorski): This is one of the signals that store needs a rebuild. 736 // TODO(fgorski): This is one of the signals that store needs a rebuild.
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 bool GCMClientImpl::HasStandaloneRegisteredApp() const { 1284 bool GCMClientImpl::HasStandaloneRegisteredApp() const {
1284 if (registrations_.empty()) 1285 if (registrations_.empty())
1285 return false; 1286 return false;
1286 // Note that account mapper is not counted as a standalone app since it is 1287 // Note that account mapper is not counted as a standalone app since it is
1287 // automatically started when other app uses GCM. 1288 // automatically started when other app uses GCM.
1288 return registrations_.size() > 1 || 1289 return registrations_.size() > 1 ||
1289 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId); 1290 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId);
1290 } 1291 }
1291 1292
1292 } // namespace gcm 1293 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_syncer.cc ('k') | components/gcm_driver/gcm_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698