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

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

Issue 10837061: gdata: Make WeakPtrFactory the last parameter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and reorder 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_auth_service.h" 5 #include "chrome/browser/chromeos/gdata/gdata_auth_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 23 matching lines...) Expand all
34 registrar_.Add(this, 34 registrar_.Add(this,
35 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, 35 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED,
36 content::Source<TokenService>(service)); 36 content::Source<TokenService>(service));
37 37
38 if (!refresh_token_.empty()) 38 if (!refresh_token_.empty())
39 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged()); 39 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged());
40 } 40 }
41 41
42 GDataAuthService::GDataAuthService() 42 GDataAuthService::GDataAuthService()
43 : profile_(NULL), 43 : profile_(NULL),
44 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 44 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
45 weak_ptr_bound_to_ui_thread_(weak_ptr_factory_.GetWeakPtr()) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 } 46 }
48 47
49 GDataAuthService::~GDataAuthService() { 48 GDataAuthService::~GDataAuthService() {
50 } 49 }
51 50
52 void GDataAuthService::StartAuthentication( 51 void GDataAuthService::StartAuthentication(
53 GDataOperationRegistry* registry, 52 GDataOperationRegistry* registry,
54 const AuthStatusCallback& callback) { 53 const AuthStatusCallback& callback) {
55 scoped_refptr<base::MessageLoopProxy> relay_proxy( 54 scoped_refptr<base::MessageLoopProxy> relay_proxy(
56 base::MessageLoopProxy::current()); 55 base::MessageLoopProxy::current());
57 56
58 if (HasAccessToken()) { 57 if (HasAccessToken()) {
59 relay_proxy->PostTask(FROM_HERE, 58 relay_proxy->PostTask(FROM_HERE,
60 base::Bind(callback, gdata::HTTP_SUCCESS, access_token_)); 59 base::Bind(callback, gdata::HTTP_SUCCESS, access_token_));
61 } else if (HasRefreshToken()) { 60 } else if (HasRefreshToken()) {
62 BrowserThread::PostTask( 61 BrowserThread::PostTask(
63 BrowserThread::UI, 62 BrowserThread::UI,
64 FROM_HERE, 63 FROM_HERE,
65 base::Bind(&GDataAuthService::StartAuthenticationOnUIThread, 64 base::Bind(&GDataAuthService::StartAuthenticationOnUIThread,
66 weak_ptr_bound_to_ui_thread_, 65 weak_ptr_factory_.GetWeakPtr(),
67 registry, 66 registry,
68 relay_proxy, 67 relay_proxy,
69 base::Bind(&GDataAuthService::OnAuthCompleted, 68 base::Bind(&GDataAuthService::OnAuthCompleted,
70 weak_ptr_bound_to_ui_thread_, 69 weak_ptr_factory_.GetWeakPtr(),
71 relay_proxy, 70 relay_proxy,
72 callback))); 71 callback)));
73 } else { 72 } else {
74 relay_proxy->PostTask(FROM_HERE, 73 relay_proxy->PostTask(FROM_HERE,
75 base::Bind(callback, gdata::HTTP_UNAUTHORIZED, std::string())); 74 base::Bind(callback, gdata::HTTP_UNAUTHORIZED, std::string()));
76 } 75 }
77 } 76 }
78 77
79 void GDataAuthService::StartAuthenticationOnUIThread( 78 void GDataAuthService::StartAuthenticationOnUIThread(
80 GDataOperationRegistry* registry, 79 GDataOperationRegistry* registry,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { 123 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
125 TokenService* service = TokenServiceFactory::GetForProfile(profile_); 124 TokenService* service = TokenServiceFactory::GetForProfile(profile_);
126 refresh_token_ = service->GetOAuth2LoginRefreshToken(); 125 refresh_token_ = service->GetOAuth2LoginRefreshToken();
127 } else { 126 } else {
128 refresh_token_.clear(); 127 refresh_token_.clear();
129 } 128 }
130 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged()); 129 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged());
131 } 130 }
132 131
133 } // namespace gdata 132 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_auth_service.h ('k') | chrome/browser/chromeos/gdata/gdata_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698