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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_operation_runner.cc

Issue 10836069: Revert 149576 - gdata: Make WeakPtrFactory the last parameter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/gdata/gdata_operation_runner.h" 5 #include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/chromeos/gdata/gdata_operations.h" 8 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 using content::BrowserThread; 12 using content::BrowserThread;
13 13
14 namespace gdata { 14 namespace gdata {
15 15
16 GDataOperationRunner::GDataOperationRunner(Profile* profile) 16 GDataOperationRunner::GDataOperationRunner(Profile* profile)
17 : profile_(profile), 17 : profile_(profile),
18 auth_service_(new GDataAuthService()), 18 auth_service_(new GDataAuthService()),
19 operation_registry_(new GDataOperationRegistry()), 19 operation_registry_(new GDataOperationRegistry()),
20 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 20 weak_ptr_factory_(this),
21 weak_ptr_bound_to_ui_thread_(weak_ptr_factory_.GetWeakPtr()) {
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
22 auth_service_->AddObserver(this); 23 auth_service_->AddObserver(this);
23 } 24 }
24 25
25 GDataOperationRunner::~GDataOperationRunner() { 26 GDataOperationRunner::~GDataOperationRunner() {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 auth_service_->RemoveObserver(this); 28 auth_service_->RemoveObserver(this);
28 } 29 }
29 30
30 void GDataOperationRunner::Initialize() { 31 void GDataOperationRunner::Initialize() {
(...skipping 11 matching lines...) Expand all
42 auth_service_->StartAuthentication(operation_registry_.get(), callback); 43 auth_service_->StartAuthentication(operation_registry_.get(), callback);
43 } 44 }
44 45
45 void GDataOperationRunner::StartOperationWithRetry( 46 void GDataOperationRunner::StartOperationWithRetry(
46 GDataOperationInterface* operation) { 47 GDataOperationInterface* operation) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
48 49
49 // The re-authenticatation callback will run on UI thread. 50 // The re-authenticatation callback will run on UI thread.
50 operation->SetReAuthenticateCallback( 51 operation->SetReAuthenticateCallback(
51 base::Bind(&GDataOperationRunner::RetryOperation, 52 base::Bind(&GDataOperationRunner::RetryOperation,
52 weak_ptr_factory_.GetWeakPtr())); 53 weak_ptr_bound_to_ui_thread_));
53 StartOperation(operation); 54 StartOperation(operation);
54 } 55 }
55 56
56 void GDataOperationRunner::StartOperation(GDataOperationInterface* operation) { 57 void GDataOperationRunner::StartOperation(GDataOperationInterface* operation) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 59
59 if (!auth_service_->HasAccessToken()) { 60 if (!auth_service_->HasAccessToken()) {
60 // Fetch OAuth2 authentication token from the refresh token first. 61 // Fetch OAuth2 authentication token from the refresh token first.
61 auth_service_->StartAuthentication( 62 auth_service_->StartAuthentication(
62 operation_registry_.get(), 63 operation_registry_.get(),
63 base::Bind(&GDataOperationRunner::OnOperationAuthRefresh, 64 base::Bind(&GDataOperationRunner::OnOperationAuthRefresh,
64 weak_ptr_factory_.GetWeakPtr(), 65 weak_ptr_bound_to_ui_thread_,
65 operation)); 66 operation));
66 return; 67 return;
67 } 68 }
68 69
69 operation->Start(auth_service_->access_token()); 70 operation->Start(auth_service_->access_token());
70 } 71 }
71 72
72 void GDataOperationRunner::OnOperationAuthRefresh( 73 void GDataOperationRunner::OnOperationAuthRefresh(
73 GDataOperationInterface* operation, 74 GDataOperationInterface* operation,
74 GDataErrorCode code, 75 GDataErrorCode code,
(...skipping 15 matching lines...) Expand all
90 // User authentication might have expired - rerun the request to force 91 // User authentication might have expired - rerun the request to force
91 // auth token refresh. 92 // auth token refresh.
92 StartOperation(operation); 93 StartOperation(operation);
93 } 94 }
94 95
95 void GDataOperationRunner::OnOAuth2RefreshTokenChanged() { 96 void GDataOperationRunner::OnOAuth2RefreshTokenChanged() {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 } 98 }
98 99
99 } // namespace gdata 100 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operation_runner.h ('k') | chrome/browser/chromeos/gdata/gdata_sync_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698