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

Side by Side Diff: chrome/browser/webdata/web_data_service.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload rebase Created 8 years, 8 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/webdata/web_data_service.h" 5 #include "chrome/browser/webdata/web_data_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 WDAppImagesResult::~WDAppImagesResult() {} 71 WDAppImagesResult::~WDAppImagesResult() {}
72 72
73 WDKeywordsResult::WDKeywordsResult() 73 WDKeywordsResult::WDKeywordsResult()
74 : default_search_provider_id(0), 74 : default_search_provider_id(0),
75 builtin_keyword_version(0) { 75 builtin_keyword_version(0) {
76 } 76 }
77 77
78 WDKeywordsResult::~WDKeywordsResult() {} 78 WDKeywordsResult::~WDKeywordsResult() {}
79 79
80 WebDataService::WebDataService() 80 WebDataService::WebDataService()
81 : is_running_(false), 81 : RefcountedProfileKeyedService(BrowserThread::UI),
82 db_(NULL), 82 is_running_(false),
83 autocomplete_syncable_service_(NULL), 83 db_(NULL),
84 autofill_profile_syncable_service_(NULL), 84 autocomplete_syncable_service_(NULL),
85 failed_init_(false), 85 autofill_profile_syncable_service_(NULL),
86 should_commit_(false), 86 failed_init_(false),
87 next_request_handle_(1), 87 should_commit_(false),
88 main_loop_(MessageLoop::current()) { 88 next_request_handle_(1),
89 main_loop_(MessageLoop::current()) {
89 } 90 }
90 91
91 // static 92 // static
92 void WebDataService::NotifyOfMultipleAutofillChanges( 93 void WebDataService::NotifyOfMultipleAutofillChanges(
93 WebDataService* web_data_service) { 94 WebDataService* web_data_service) {
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
95 96
96 if (!web_data_service) 97 if (!web_data_service)
97 return; 98 return;
98 99
99 BrowserThread::PostTask( 100 BrowserThread::PostTask(
100 BrowserThread::UI, FROM_HERE, 101 BrowserThread::UI, FROM_HERE,
101 Bind(&NotifyOfMultipleAutofillChangesTask, 102 Bind(&NotifyOfMultipleAutofillChangesTask,
102 make_scoped_refptr(web_data_service))); 103 make_scoped_refptr(web_data_service)));
103 } 104 }
104 105
106 void WebDataService::ShutdownOnUIThread() {
107 ScheduleTask(FROM_HERE,
108 Bind(&WebDataService::ShutdownSyncableServices, this));
109 UnloadDatabase();
110 }
111
105 bool WebDataService::Init(const FilePath& profile_path) { 112 bool WebDataService::Init(const FilePath& profile_path) {
106 FilePath path = profile_path; 113 FilePath path = profile_path;
107 path = path.Append(chrome::kWebDataFilename); 114 path = path.Append(chrome::kWebDataFilename);
108 return InitWithPath(path); 115 return InitWithPath(path);
109 } 116 }
110 117
111 void WebDataService::Shutdown() {
112 ScheduleTask(FROM_HERE,
113 Bind(&WebDataService::ShutdownSyncableServices, this));
114 UnloadDatabase();
115 }
116
117 bool WebDataService::IsRunning() const { 118 bool WebDataService::IsRunning() const {
118 return is_running_; 119 return is_running_;
119 } 120 }
120 121
121 void WebDataService::UnloadDatabase() { 122 void WebDataService::UnloadDatabase() {
122 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); 123 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this));
123 } 124 }
124 125
125 void WebDataService::CancelRequest(Handle h) { 126 void WebDataService::CancelRequest(Handle h) {
126 base::AutoLock l(pending_lock_); 127 base::AutoLock l(pending_lock_);
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1653 }
1653 1654
1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1655 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1655 return result_; 1656 return result_;
1656 } 1657 }
1657 1658
1658 void WebDataService::WebDataRequest::RequestComplete() { 1659 void WebDataService::WebDataRequest::RequestComplete() {
1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1660 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1660 service_.get(), handle_)); 1661 service_.get(), handle_));
1661 } 1662 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service.h ('k') | chrome/browser/webdata/web_data_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698