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

Side by Side Diff: components/webdata/common/web_database_service.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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
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 "components/webdata/common/web_database_service.h" 5 #include "components/webdata/common/web_database_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h"
9 #include "components/webdata/common/web_data_request_manager.h" 10 #include "components/webdata/common/web_data_request_manager.h"
10 #include "components/webdata/common/web_data_results.h" 11 #include "components/webdata/common/web_data_results.h"
11 #include "components/webdata/common/web_data_service_consumer.h" 12 #include "components/webdata/common/web_data_service_consumer.h"
12 #include "components/webdata/common/web_database_backend.h" 13 #include "components/webdata/common/web_database_backend.h"
13 14
14 using base::Bind; 15 using base::Bind;
15 using base::FilePath; 16 using base::FilePath;
16 17
17 // Receives messages from the backend on the DB thread, posts them to 18 // Receives messages from the backend on the DB thread, posts them to
18 // WebDatabaseService on the UI thread. 19 // WebDatabaseService on the UI thread.
19 class WebDatabaseService::BackendDelegate 20 class WebDatabaseService::BackendDelegate
20 : public WebDatabaseBackend::Delegate { 21 : public WebDatabaseBackend::Delegate {
21 public: 22 public:
22 BackendDelegate( 23 BackendDelegate(const base::WeakPtr<WebDatabaseService>& web_database_service)
23 const base::WeakPtr<WebDatabaseService>& web_database_service)
24 : web_database_service_(web_database_service), 24 : web_database_service_(web_database_service),
25 callback_thread_(base::MessageLoopProxy::current()) { 25 callback_thread_(base::ThreadTaskRunnerHandle::Get()) {}
26 }
27 26
28 void DBLoaded(sql::InitStatus status) override { 27 void DBLoaded(sql::InitStatus status) override {
29 callback_thread_->PostTask( 28 callback_thread_->PostTask(
30 FROM_HERE, 29 FROM_HERE,
31 base::Bind(&WebDatabaseService::OnDatabaseLoadDone, 30 base::Bind(&WebDatabaseService::OnDatabaseLoadDone,
32 web_database_service_, 31 web_database_service_,
33 status)); 32 status));
34 } 33 }
35 private: 34 private:
36 const base::WeakPtr<WebDatabaseService> web_database_service_; 35 const base::WeakPtr<WebDatabaseService> web_database_service_;
37 scoped_refptr<base::MessageLoopProxy> callback_thread_; 36 scoped_refptr<base::SingleThreadTaskRunner> callback_thread_;
38 }; 37 };
39 38
40 WebDatabaseService::WebDatabaseService( 39 WebDatabaseService::WebDatabaseService(
41 const base::FilePath& path, 40 const base::FilePath& path,
42 const scoped_refptr<base::MessageLoopProxy>& ui_thread, 41 scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
43 const scoped_refptr<base::MessageLoopProxy>& db_thread) 42 scoped_refptr<base::SingleThreadTaskRunner> db_thread)
44 : base::RefCountedDeleteOnMessageLoop<WebDatabaseService>(ui_thread), 43 : base::RefCountedDeleteOnMessageLoop<WebDatabaseService>(ui_thread),
45 path_(path), 44 path_(path),
46 db_loaded_(false), 45 db_loaded_(false),
47 db_thread_(db_thread), 46 db_thread_(db_thread),
48 weak_ptr_factory_(this) { 47 weak_ptr_factory_(this) {
49 // WebDatabaseService should be instantiated on UI thread. 48 // WebDatabaseService should be instantiated on UI thread.
50 DCHECK(ui_thread->BelongsToCurrentThread()); 49 DCHECK(ui_thread->BelongsToCurrentThread());
51 // WebDatabaseService requires DB thread if instantiated. 50 // WebDatabaseService requires DB thread if instantiated.
52 DCHECK(db_thread.get()); 51 DCHECK(db_thread.get());
53 } 52 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } else { 143 } else {
145 // Notify that the database load failed. 144 // Notify that the database load failed.
146 for (size_t i = 0; i < error_callbacks_.size(); i++) { 145 for (size_t i = 0; i < error_callbacks_.size(); i++) {
147 if (!error_callbacks_[i].is_null()) 146 if (!error_callbacks_[i].is_null())
148 error_callbacks_[i].Run(status); 147 error_callbacks_[i].Run(status);
149 } 148 }
150 149
151 error_callbacks_.clear(); 150 error_callbacks_.clear();
152 } 151 }
153 } 152 }
OLDNEW
« no previous file with comments | « components/webdata/common/web_database_service.h ('k') | components/webdata_services/web_data_service_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698