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

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

Issue 10837338: Remove "GData" prefix from non-GData specific classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. 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/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 OperationRunner::OperationRunner(Profile* profile)
17 : profile_(profile), 17 : profile_(profile),
18 auth_service_(new GDataAuthService()), 18 auth_service_(new AuthService()),
19 operation_registry_(new GDataOperationRegistry()), 19 operation_registry_(new OperationRegistry()),
20 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 20 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
22 auth_service_->AddObserver(this); 22 auth_service_->AddObserver(this);
23 } 23 }
24 24
25 GDataOperationRunner::~GDataOperationRunner() { 25 OperationRunner::~OperationRunner() {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 auth_service_->RemoveObserver(this); 27 auth_service_->RemoveObserver(this);
28 } 28 }
29 29
30 void GDataOperationRunner::Initialize() { 30 void OperationRunner::Initialize() {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 auth_service_->Initialize(profile_); 32 auth_service_->Initialize(profile_);
33 } 33 }
34 34
35 void GDataOperationRunner::CancelAll() { 35 void OperationRunner::CancelAll() {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 operation_registry_->CancelAll(); 37 operation_registry_->CancelAll();
38 } 38 }
39 39
40 void GDataOperationRunner::Authenticate(const AuthStatusCallback& callback) { 40 void OperationRunner::Authenticate(const AuthStatusCallback& callback) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
42 auth_service_->StartAuthentication(operation_registry_.get(), callback); 42 auth_service_->StartAuthentication(operation_registry_.get(), callback);
43 } 43 }
44 44
45 void GDataOperationRunner::StartOperationWithRetry( 45 void OperationRunner::StartOperationWithRetry(
46 GDataOperationInterface* operation) { 46 GDataOperationInterface* operation) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
48 48
49 // The re-authenticatation callback will run on UI thread. 49 // The re-authenticatation callback will run on UI thread.
50 operation->SetReAuthenticateCallback( 50 operation->SetReAuthenticateCallback(
51 base::Bind(&GDataOperationRunner::RetryOperation, 51 base::Bind(&OperationRunner::RetryOperation,
52 weak_ptr_factory_.GetWeakPtr())); 52 weak_ptr_factory_.GetWeakPtr()));
53 StartOperation(operation); 53 StartOperation(operation);
54 } 54 }
55 55
56 void GDataOperationRunner::StartOperation(GDataOperationInterface* operation) { 56 void OperationRunner::StartOperation(GDataOperationInterface* operation) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 58
59 if (!auth_service_->HasAccessToken()) { 59 if (!auth_service_->HasAccessToken()) {
60 // Fetch OAuth2 authentication token from the refresh token first. 60 // Fetch OAuth2 authentication token from the refresh token first.
61 auth_service_->StartAuthentication( 61 auth_service_->StartAuthentication(
62 operation_registry_.get(), 62 operation_registry_.get(),
63 base::Bind(&GDataOperationRunner::OnOperationAuthRefresh, 63 base::Bind(&OperationRunner::OnOperationAuthRefresh,
64 weak_ptr_factory_.GetWeakPtr(), 64 weak_ptr_factory_.GetWeakPtr(),
65 operation)); 65 operation));
66 return; 66 return;
67 } 67 }
68 68
69 operation->Start(auth_service_->access_token()); 69 operation->Start(auth_service_->access_token());
70 } 70 }
71 71
72 void GDataOperationRunner::OnOperationAuthRefresh( 72 void OperationRunner::OnOperationAuthRefresh(
73 GDataOperationInterface* operation, 73 GDataOperationInterface* operation,
74 GDataErrorCode code, 74 GDataErrorCode code,
75 const std::string& auth_token) { 75 const std::string& auth_token) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 77
78 if (code == HTTP_SUCCESS) { 78 if (code == HTTP_SUCCESS) {
79 DCHECK(auth_service_->HasRefreshToken()); 79 DCHECK(auth_service_->HasRefreshToken());
80 StartOperation(operation); 80 StartOperation(operation);
81 } else { 81 } else {
82 operation->OnAuthFailed(code); 82 operation->OnAuthFailed(code);
83 } 83 }
84 } 84 }
85 85
86 void GDataOperationRunner::RetryOperation(GDataOperationInterface* operation) { 86 void OperationRunner::RetryOperation(GDataOperationInterface* operation) {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
88 88
89 auth_service_->ClearAccessToken(); 89 auth_service_->ClearAccessToken();
90 // User authentication might have expired - rerun the request to force 90 // User authentication might have expired - rerun the request to force
91 // auth token refresh. 91 // auth token refresh.
92 StartOperation(operation); 92 StartOperation(operation);
93 } 93 }
94 94
95 void GDataOperationRunner::OnOAuth2RefreshTokenChanged() { 95 void OperationRunner::OnOAuth2RefreshTokenChanged() {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 } 97 }
98 98
99 } // namespace gdata 99 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/operation_runner.h ('k') | chrome/browser/chromeos/gdata/operations_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698