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

Side by Side Diff: chrome/browser/sync/profile_sync_auth_provider.cc

Issue 1128523002: Usage of ThreadTaskRunner in lieu of in [chrome/browser/sync],[components/sync_driver] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review Comments Created 5 years, 7 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/sync/profile_sync_auth_provider.h" 5 #include "chrome/browser/sync/profile_sync_auth_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "components/signin/core/browser/profile_oauth2_token_service.h" 11 #include "components/signin/core/browser/profile_oauth2_token_service.h"
12 #include "google_apis/gaia/gaia_constants.h" 12 #include "google_apis/gaia/gaia_constants.h"
13 13
14 // This is thin proxy class for forwarding calls between sync and UI threads. 14 // This is thin proxy class for forwarding calls between sync and UI threads.
15 // The main purpose is to hide the fact that ProfileSyncAuthProvider and 15 // The main purpose is to hide the fact that ProfileSyncAuthProvider and
16 // SyncThreadProxy have independent lifetimes. If ProfileSyncAuthProvider is 16 // SyncThreadProxy have independent lifetimes. If ProfileSyncAuthProvider is
17 // destroyed first calls to RequestAccessToken will never complete. This is fine 17 // destroyed first calls to RequestAccessToken will never complete. This is fine
18 // since sync thread is not blocked and is in the process of shutdown anyway. 18 // since sync thread is not blocked and is in the process of shutdown anyway.
19 class ProfileSyncAuthProvider::SyncThreadProxy 19 class ProfileSyncAuthProvider::SyncThreadProxy
20 : public syncer::SyncAuthProvider, 20 : public syncer::SyncAuthProvider,
(...skipping 26 matching lines...) Expand all
47 } 47 }
48 48
49 void ProfileSyncAuthProvider::SyncThreadProxy::RequestAccessToken( 49 void ProfileSyncAuthProvider::SyncThreadProxy::RequestAccessToken(
50 const RequestTokenCallback& callback) { 50 const RequestTokenCallback& callback) {
51 DCHECK(CalledOnValidThread()); 51 DCHECK(CalledOnValidThread());
52 provider_task_runner_->PostTask( 52 provider_task_runner_->PostTask(
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(&ProfileSyncAuthProvider::RequestAccessToken, 54 base::Bind(&ProfileSyncAuthProvider::RequestAccessToken,
55 provider_impl_, 55 provider_impl_,
56 callback, 56 callback,
57 base::MessageLoopProxy::current())); 57 base::ThreadTaskRunnerHandle::Get()));
58 } 58 }
59 59
60 void ProfileSyncAuthProvider::SyncThreadProxy::InvalidateAccessToken( 60 void ProfileSyncAuthProvider::SyncThreadProxy::InvalidateAccessToken(
61 const std::string& token) { 61 const std::string& token) {
62 DCHECK(CalledOnValidThread()); 62 DCHECK(CalledOnValidThread());
63 provider_task_runner_->PostTask( 63 provider_task_runner_->PostTask(
64 FROM_HERE, 64 FROM_HERE,
65 base::Bind(&ProfileSyncAuthProvider::InvalidateAccessToken, 65 base::Bind(&ProfileSyncAuthProvider::InvalidateAccessToken,
66 provider_impl_, 66 provider_impl_,
67 token)); 67 token));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void ProfileSyncAuthProvider::InvalidateAccessToken(const std::string& token) { 126 void ProfileSyncAuthProvider::InvalidateAccessToken(const std::string& token) {
127 DCHECK(CalledOnValidThread()); 127 DCHECK(CalledOnValidThread());
128 token_service_->InvalidateToken(account_id_, oauth2_scope_, token); 128 token_service_->InvalidateToken(account_id_, oauth2_scope_, token);
129 } 129 }
130 130
131 scoped_ptr<syncer::SyncAuthProvider> 131 scoped_ptr<syncer::SyncAuthProvider>
132 ProfileSyncAuthProvider::CreateProviderForSyncThread() { 132 ProfileSyncAuthProvider::CreateProviderForSyncThread() {
133 DCHECK(CalledOnValidThread()); 133 DCHECK(CalledOnValidThread());
134 scoped_ptr<syncer::SyncAuthProvider> auth_provider(new SyncThreadProxy( 134 scoped_ptr<syncer::SyncAuthProvider> auth_provider(new SyncThreadProxy(
135 weak_factory_.GetWeakPtr(), base::MessageLoopProxy::current())); 135 weak_factory_.GetWeakPtr(), base::ThreadTaskRunnerHandle::Get()));
136 return auth_provider.Pass(); 136 return auth_provider.Pass();
137 } 137 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698