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

Side by Side Diff: chrome/browser/services/gcm/gcm_account_tracker.cc

Issue 1143343005: chrome/browser: 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 "chrome/browser/services/gcm/gcm_account_tracker.h" 5 #include "chrome/browser/services/gcm/gcm_account_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "components/gcm_driver/gcm_driver.h" 15 #include "components/gcm_driver/gcm_driver.h"
14 #include "google_apis/gaia/google_service_auth_error.h" 16 #include "google_apis/gaia/google_service_auth_error.h"
15 #include "net/base/ip_endpoint.h" 17 #include "net/base/ip_endpoint.h"
16 18
17 namespace gcm { 19 namespace gcm {
18 20
19 namespace { 21 namespace {
20 22
21 // Scopes needed by the OAuth2 access tokens. 23 // Scopes needed by the OAuth2 access tokens.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void GCMAccountTracker::ScheduleReportTokens() { 86 void GCMAccountTracker::ScheduleReportTokens() {
85 // Shortcutting here, in case GCM Driver is not yet connected. In that case 87 // Shortcutting here, in case GCM Driver is not yet connected. In that case
86 // reporting will be scheduled/started when the connection is made. 88 // reporting will be scheduled/started when the connection is made.
87 if (!driver_->IsConnected()) 89 if (!driver_->IsConnected())
88 return; 90 return;
89 91
90 DVLOG(1) << "Deferring the token reporting for: " 92 DVLOG(1) << "Deferring the token reporting for: "
91 << GetTimeToNextTokenReporting().InSeconds() << " seconds."; 93 << GetTimeToNextTokenReporting().InSeconds() << " seconds.";
92 94
93 reporting_weak_ptr_factory_.InvalidateWeakPtrs(); 95 reporting_weak_ptr_factory_.InvalidateWeakPtrs();
94 base::MessageLoop::current()->PostDelayedTask( 96 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
95 FROM_HERE, 97 FROM_HERE, base::Bind(&GCMAccountTracker::ReportTokens,
96 base::Bind(&GCMAccountTracker::ReportTokens, 98 reporting_weak_ptr_factory_.GetWeakPtr()),
97 reporting_weak_ptr_factory_.GetWeakPtr()),
98 GetTimeToNextTokenReporting()); 99 GetTimeToNextTokenReporting());
99 } 100 }
100 101
101 void GCMAccountTracker::OnAccountAdded(const gaia::AccountIds& ids) { 102 void GCMAccountTracker::OnAccountAdded(const gaia::AccountIds& ids) {
102 DVLOG(1) << "Account added: " << ids.email; 103 DVLOG(1) << "Account added: " << ids.email;
103 // We listen for the account signing in, which happens after account is added. 104 // We listen for the account signing in, which happens after account is added.
104 } 105 }
105 106
106 void GCMAccountTracker::OnAccountRemoved(const gaia::AccountIds& ids) { 107 void GCMAccountTracker::OnAccountRemoved(const gaia::AccountIds& ids) {
107 DVLOG(1) << "Account removed: " << ids.email; 108 DVLOG(1) << "Account removed: " << ids.email;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 iter->second.state = ACCOUNT_REMOVED; 367 iter->second.state = ACCOUNT_REMOVED;
367 ReportTokens(); 368 ReportTokens();
368 } 369 }
369 370
370 OAuth2TokenService* GCMAccountTracker::GetTokenService() { 371 OAuth2TokenService* GCMAccountTracker::GetTokenService() {
371 DCHECK(account_tracker_->identity_provider()); 372 DCHECK(account_tracker_->identity_provider());
372 return account_tracker_->identity_provider()->GetTokenService(); 373 return account_tracker_->identity_provider()->GetTokenService();
373 } 374 }
374 375
375 } // namespace gcm 376 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_profile_service.cc ('k') | chrome/browser/services/gcm/gcm_account_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698