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

Side by Side Diff: chrome/browser/sync/glue/autofill_data_type_controller.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 (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/sync/glue/autofill_data_type_controller.h" 5 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/profile_sync_components_factory.h" 10 #include "chrome/browser/sync/profile_sync_components_factory.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 syncer::ModelSafeGroup AutofillDataTypeController::model_safe_group() const { 35 syncer::ModelSafeGroup AutofillDataTypeController::model_safe_group() const {
36 return syncer::GROUP_DB; 36 return syncer::GROUP_DB;
37 } 37 }
38 38
39 void AutofillDataTypeController::WebDatabaseLoaded() { 39 void AutofillDataTypeController::WebDatabaseLoaded() {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 DCHECK_EQ(MODEL_STARTING, state()); 41 DCHECK_EQ(MODEL_STARTING, state());
42 42
43 if (web_data_service_) 43 if (web_data_service_.get())
44 web_data_service_->RemoveDBObserver(this); 44 web_data_service_->RemoveDBObserver(this);
45 45
46 OnModelLoaded(); 46 OnModelLoaded();
47 } 47 }
48 48
49 AutofillDataTypeController::~AutofillDataTypeController() { 49 AutofillDataTypeController::~AutofillDataTypeController() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 if (web_data_service_) 51 if (web_data_service_.get())
52 web_data_service_->RemoveDBObserver(this); 52 web_data_service_->RemoveDBObserver(this);
53 } 53 }
54 54
55 bool AutofillDataTypeController::PostTaskOnBackendThread( 55 bool AutofillDataTypeController::PostTaskOnBackendThread(
56 const tracked_objects::Location& from_here, 56 const tracked_objects::Location& from_here,
57 const base::Closure& task) { 57 const base::Closure& task) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
59 return BrowserThread::PostTask(BrowserThread::DB, from_here, task); 59 return BrowserThread::PostTask(BrowserThread::DB, from_here, task);
60 } 60 }
61 61
62 bool AutofillDataTypeController::StartModels() { 62 bool AutofillDataTypeController::StartModels() {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 DCHECK_EQ(MODEL_STARTING, state()); 64 DCHECK_EQ(MODEL_STARTING, state());
65 65
66 web_data_service_ = 66 web_data_service_ =
67 autofill::AutofillWebDataService::FromBrowserContext(profile()); 67 autofill::AutofillWebDataService::FromBrowserContext(profile());
68 if (web_data_service_->IsDatabaseLoaded()) { 68 if (web_data_service_->IsDatabaseLoaded()) {
69 return true; 69 return true;
70 } else { 70 } else {
71 if (web_data_service_) 71 if (web_data_service_.get())
72 web_data_service_->AddDBObserver(this); 72 web_data_service_->AddDBObserver(this);
73 return false; 73 return false;
74 } 74 }
75 } 75 }
76 76
77 void AutofillDataTypeController::StopModels() { 77 void AutofillDataTypeController::StopModels() {
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
79 DCHECK(state() == STOPPING || state() == NOT_RUNNING || state() == DISABLED); 79 DCHECK(state() == STOPPING || state() == NOT_RUNNING || state() == DISABLED);
80 DVLOG(1) << "AutofillDataTypeController::StopModels() : State = " << state(); 80 DVLOG(1) << "AutofillDataTypeController::StopModels() : State = " << state();
81 if (web_data_service_) 81 if (web_data_service_.get())
82 web_data_service_->RemoveDBObserver(this); 82 web_data_service_->RemoveDBObserver(this);
83 } 83 }
84 84
85 void AutofillDataTypeController::StartAssociating( 85 void AutofillDataTypeController::StartAssociating(
86 const StartCallback& start_callback) { 86 const StartCallback& start_callback) {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
88 DCHECK_EQ(state(), MODEL_LOADED); 88 DCHECK_EQ(state(), MODEL_LOADED);
89 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile( 89 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(
90 profile()); 90 profile());
91 DCHECK(sync); 91 DCHECK(sync);
92 bool cull_expired_entries = sync->current_experiments().autofill_culling; 92 bool cull_expired_entries = sync->current_experiments().autofill_culling;
93 // First, post the update task to the DB thread, which guarantees us it 93 // First, post the update task to the DB thread, which guarantees us it
94 // would run before anything StartAssociating does (e.g. 94 // would run before anything StartAssociating does (e.g.
95 // MergeDataAndStartSyncing). 95 // MergeDataAndStartSyncing).
96 PostTaskOnBackendThread( 96 PostTaskOnBackendThread(
97 FROM_HERE, 97 FROM_HERE,
98 base::Bind( 98 base::Bind(
99 &AutofillDataTypeController::UpdateAutofillCullingSettings, 99 &AutofillDataTypeController::UpdateAutofillCullingSettings,
100 this, 100 this,
101 cull_expired_entries)); 101 cull_expired_entries));
102 NonUIDataTypeController::StartAssociating(start_callback); 102 NonUIDataTypeController::StartAssociating(start_callback);
103 } 103 }
104 104
105 void AutofillDataTypeController::UpdateAutofillCullingSettings( 105 void AutofillDataTypeController::UpdateAutofillCullingSettings(
106 bool cull_expired_entries) { 106 bool cull_expired_entries) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
108 AutocompleteSyncableService* service = 108 AutocompleteSyncableService* service =
109 AutocompleteSyncableService::FromWebDataService(web_data_service_); 109 AutocompleteSyncableService::FromWebDataService(web_data_service_.get());
110 if (!service) { 110 if (!service) {
111 DVLOG(1) << "Can't update culling, no AutocompleteSyncableService."; 111 DVLOG(1) << "Can't update culling, no AutocompleteSyncableService.";
112 return; 112 return;
113 } 113 }
114 114
115 service->UpdateCullSetting(cull_expired_entries); 115 service->UpdateCullSetting(cull_expired_entries);
116 } 116 }
117 117
118 } // namespace browser_sync 118 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_tab_helper.cc ('k') | chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698