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

Side by Side Diff: chrome/browser/signin/token_service.cc

Issue 16154031: Un-refcount AutofillWebData and TokenWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/signin/token_service.h" 5 #include "chrome/browser/signin/token_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, \ 42 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, \
43 signin_diagnostics_observers_, \ 43 signin_diagnostics_observers_, \
44 func); \ 44 func); \
45 } while (0) \ 45 } while (0) \
46 46
47 } // namespace 47 } // namespace
48 48
49 49
50 TokenService::TokenService() 50 TokenService::TokenService()
51 : profile_(NULL), 51 : profile_(NULL),
52 token_web_data_(NULL),
52 token_loading_query_(0), 53 token_loading_query_(0),
53 tokens_loaded_(false) { 54 tokens_loaded_(false) {
54 // Allow constructor to be called outside the UI thread, so it can be mocked 55 // Allow constructor to be called outside the UI thread, so it can be mocked
55 // out for unit tests. 56 // out for unit tests.
56 57
57 COMPILE_ASSERT(arraysize(kServices) == arraysize(fetchers_), 58 COMPILE_ASSERT(arraysize(kServices) == arraysize(fetchers_),
58 kServices_and_fetchers_dont_have_same_size); 59 kServices_and_fetchers_dont_have_same_size);
59 } 60 }
60 61
61 TokenService::~TokenService() { 62 TokenService::~TokenService() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged(LSID, credentials.lsid)); 169 FOR_DIAGNOSTICS_OBSERVERS(NotifySigninValueChanged(LSID, credentials.lsid));
169 } 170 }
170 171
171 void TokenService::UpdateCredentialsWithOAuth2( 172 void TokenService::UpdateCredentialsWithOAuth2(
172 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { 173 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
173 SaveOAuth2Credentials(oauth2_tokens); 174 SaveOAuth2Credentials(oauth2_tokens);
174 } 175 }
175 176
176 void TokenService::LoadTokensFromDB() { 177 void TokenService::LoadTokensFromDB() {
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
178 if (token_web_data_.get()) 179 if (token_web_data_)
179 token_loading_query_ = token_web_data_->GetAllTokens(this); 180 token_loading_query_ = token_web_data_->GetAllTokens(this);
180 } 181 }
181 182
182 void TokenService::SaveAuthTokenToDB(const std::string& service, 183 void TokenService::SaveAuthTokenToDB(const std::string& service,
183 const std::string& auth_token) { 184 const std::string& auth_token) {
184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
185 if (token_web_data_.get()) 186 if (token_web_data_)
186 token_web_data_->SetTokenForService(service, auth_token); 187 token_web_data_->SetTokenForService(service, auth_token);
187 } 188 }
188 189
189 void TokenService::EraseTokensFromDB() { 190 void TokenService::EraseTokensFromDB() {
190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
191 if (token_web_data_.get()) 192 if (token_web_data_)
192 token_web_data_->RemoveAllTokens(); 193 token_web_data_->RemoveAllTokens();
193 194
194 content::NotificationService::current()->Notify( 195 content::NotificationService::current()->Notify(
195 chrome::NOTIFICATION_TOKENS_CLEARED, 196 chrome::NOTIFICATION_TOKENS_CLEARED,
196 content::Source<TokenService>(this), 197 content::Source<TokenService>(this),
197 content::NotificationService::NoDetails()); 198 content::NotificationService::NoDetails());
198 199
199 // Clear in-memory token values stored by AboutSigninInternals 200 // Clear in-memory token values stored by AboutSigninInternals
200 // Note that although this is clearing in-memory values, it belongs here and 201 // Note that although this is clearing in-memory values, it belongs here and
201 // not in ResetCredentialsInMemory() (which is invoked both on sign out and 202 // not in ResetCredentialsInMemory() (which is invoked both on sign out and
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 457
457 void TokenService::AddSigninDiagnosticsObserver( 458 void TokenService::AddSigninDiagnosticsObserver(
458 SigninDiagnosticsObserver* observer) { 459 SigninDiagnosticsObserver* observer) {
459 signin_diagnostics_observers_.AddObserver(observer); 460 signin_diagnostics_observers_.AddObserver(observer);
460 } 461 }
461 462
462 void TokenService::RemoveSigninDiagnosticsObserver( 463 void TokenService::RemoveSigninDiagnosticsObserver(
463 SigninDiagnosticsObserver* observer) { 464 SigninDiagnosticsObserver* observer) {
464 signin_diagnostics_observers_.RemoveObserver(observer); 465 signin_diagnostics_observers_.RemoveObserver(observer);
465 } 466 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/token_service.h ('k') | chrome/browser/sync/glue/autofill_data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698