Commit 311c8fce authored by zhuoyu.qian's avatar zhuoyu.qian Committed by Commit bot

Rename WebDataServiceBackend to WebDatabaseBackend

As the comment in web_data_service_backend.h by caitkp@,
rename WebDataServiceBackend to WebDatabaseBackend and related class.
Rename the files also.

BUG=
R=caitkp@chromium.org

Review URL: https://codereview.chromium.org/962903003

Cr-Commit-Position: refs/heads/master@{#320638}
parent 2f725731
......@@ -17,7 +17,7 @@
#include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service_observer.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/webdata/common/web_data_service_backend.h"
#include "components/webdata/common/web_database_backend.h"
using base::Bind;
using base::Time;
......@@ -25,7 +25,7 @@ using base::Time;
namespace autofill {
AutofillWebDataBackendImpl::AutofillWebDataBackendImpl(
scoped_refptr<WebDataServiceBackend> web_database_backend,
scoped_refptr<WebDatabaseBackend> web_database_backend,
scoped_refptr<base::MessageLoopProxy> ui_thread,
scoped_refptr<base::MessageLoopProxy> db_thread,
const base::Closure& on_changed_callback)
......
......@@ -22,7 +22,7 @@ namespace base {
class MessageLoopProxy;
}
class WebDataServiceBackend;
class WebDatabaseBackend;
namespace autofill {
......@@ -47,7 +47,7 @@ class AutofillWebDataBackendImpl
// thread of changes initiated by Sync (this callback may be called multiple
// times).
AutofillWebDataBackendImpl(
scoped_refptr<WebDataServiceBackend> web_database_backend,
scoped_refptr<WebDatabaseBackend> web_database_backend,
scoped_refptr<base::MessageLoopProxy> ui_thread,
scoped_refptr<base::MessageLoopProxy> db_thread,
const base::Closure& on_changed_callback);
......@@ -201,9 +201,9 @@ class AutofillWebDataBackendImpl
ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
// WebDataServiceBackend allows direct access to DB.
// WebDatabaseBackend allows direct access to DB.
// TODO(caitkp): Make it so nobody but us needs direct DB access anymore.
scoped_refptr<WebDataServiceBackend> web_database_backend_;
scoped_refptr<WebDatabaseBackend> web_database_backend_;
base::Closure on_changed_callback_;
......
......@@ -17,7 +17,7 @@
#include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service_observer.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/webdata/common/web_data_service_backend.h"
#include "components/webdata/common/web_database_backend.h"
#include "components/webdata/common/web_database_service.h"
using base::Bind;
......
......@@ -22,13 +22,13 @@
'webdata/common/web_data_request_manager.cc',
'webdata/common/web_data_request_manager.h',
'webdata/common/web_data_results.h',
'webdata/common/web_data_service_backend.cc',
'webdata/common/web_data_service_backend.h',
'webdata/common/web_data_service_base.cc',
'webdata/common/web_data_service_base.h',
'webdata/common/web_data_service_consumer.h',
'webdata/common/web_database.cc',
'webdata/common/web_database.h',
'webdata/common/web_database_backend.cc',
'webdata/common/web_database_backend.h',
'webdata/common/web_database_service.cc',
'webdata/common/web_database_service.h',
'webdata/common/web_database_table.cc',
......
......@@ -9,13 +9,13 @@ component("common") {
"web_data_request_manager.cc",
"web_data_request_manager.h",
"web_data_results.h",
"web_data_service_backend.cc",
"web_data_service_backend.h",
"web_data_service_base.cc",
"web_data_service_base.h",
"web_data_service_consumer.h",
"web_database.cc",
"web_database.h",
"web_database_backend.cc",
"web_database_backend.h",
"web_database_service.cc",
"web_database_service.h",
"web_database_table.cc",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/webdata/common/web_data_service_backend.h"
#include "components/webdata/common/web_database_backend.h"
#include "base/bind.h"
#include "base/location.h"
......@@ -13,11 +13,11 @@
using base::Bind;
using base::FilePath;
WebDataServiceBackend::WebDataServiceBackend(
WebDatabaseBackend::WebDatabaseBackend(
const FilePath& path,
Delegate* delegate,
const scoped_refptr<base::MessageLoopProxy>& db_thread)
: base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend>(db_thread),
: base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>(db_thread),
db_path_(path),
request_manager_(new WebDataRequestManager()),
init_status_(sql::INIT_FAILURE),
......@@ -25,19 +25,19 @@ WebDataServiceBackend::WebDataServiceBackend(
delegate_(delegate) {
}
void WebDataServiceBackend::AddTable(scoped_ptr<WebDatabaseTable> table) {
void WebDatabaseBackend::AddTable(scoped_ptr<WebDatabaseTable> table) {
DCHECK(!db_.get());
tables_.push_back(table.release());
}
void WebDataServiceBackend::InitDatabase() {
void WebDatabaseBackend::InitDatabase() {
LoadDatabaseIfNecessary();
if (delegate_) {
delegate_->DBLoaded(init_status_);
}
}
sql::InitStatus WebDataServiceBackend::LoadDatabaseIfNecessary() {
sql::InitStatus WebDatabaseBackend::LoadDatabaseIfNecessary() {
if (init_complete_ || db_path_.empty()) {
return init_status_;
}
......@@ -60,7 +60,7 @@ sql::InitStatus WebDataServiceBackend::LoadDatabaseIfNecessary() {
return init_status_;
}
void WebDataServiceBackend::ShutdownDatabase() {
void WebDatabaseBackend::ShutdownDatabase() {
if (db_ && init_status_ == sql::INIT_OK)
db_->CommitTransaction();
db_.reset(NULL);
......@@ -68,7 +68,7 @@ void WebDataServiceBackend::ShutdownDatabase() {
init_status_ = sql::INIT_FAILURE;
}
void WebDataServiceBackend::DBWriteTaskWrapper(
void WebDatabaseBackend::DBWriteTaskWrapper(
const WebDatabaseService::WriteTask& task,
scoped_ptr<WebDataRequest> request) {
if (request->IsCancelled())
......@@ -78,7 +78,7 @@ void WebDataServiceBackend::DBWriteTaskWrapper(
request_manager_->RequestCompleted(request.Pass());
}
void WebDataServiceBackend::ExecuteWriteTask(
void WebDatabaseBackend::ExecuteWriteTask(
const WebDatabaseService::WriteTask& task) {
LoadDatabaseIfNecessary();
if (db_ && init_status_ == sql::INIT_OK) {
......@@ -88,7 +88,7 @@ void WebDataServiceBackend::ExecuteWriteTask(
}
}
void WebDataServiceBackend::DBReadTaskWrapper(
void WebDatabaseBackend::DBReadTaskWrapper(
const WebDatabaseService::ReadTask& task,
scoped_ptr<WebDataRequest> request) {
if (request->IsCancelled())
......@@ -98,7 +98,7 @@ void WebDataServiceBackend::DBReadTaskWrapper(
request_manager_->RequestCompleted(request.Pass());
}
scoped_ptr<WDTypedResult> WebDataServiceBackend::ExecuteReadTask(
scoped_ptr<WDTypedResult> WebDatabaseBackend::ExecuteReadTask(
const WebDatabaseService::ReadTask& task) {
LoadDatabaseIfNecessary();
if (db_ && init_status_ == sql::INIT_OK) {
......@@ -107,11 +107,11 @@ scoped_ptr<WDTypedResult> WebDataServiceBackend::ExecuteReadTask(
return scoped_ptr<WDTypedResult>();
}
WebDataServiceBackend::~WebDataServiceBackend() {
WebDatabaseBackend::~WebDatabaseBackend() {
ShutdownDatabase();
}
void WebDataServiceBackend::Commit() {
void WebDatabaseBackend::Commit() {
DCHECK(db_);
DCHECK_EQ(sql::INIT_OK, init_status_);
db_->CommitTransaction();
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
#define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
#ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_
#define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_
#include "base/basictypes.h"
#include "base/callback_forward.h"
......@@ -25,14 +25,12 @@ namespace tracked_objects {
class Location;
}
// WebDataServiceBackend handles all database tasks posted by
// WebDatabaseBackend handles all database tasks posted by
// WebDatabaseService. It is refcounted to allow asynchronous destruction on the
// DB thread.
// TODO(caitkp): Rename this class to WebDatabaseBackend.
class WEBDATA_EXPORT WebDataServiceBackend
: public base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend> {
class WEBDATA_EXPORT WebDatabaseBackend
: public base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend> {
public:
class Delegate {
public:
......@@ -42,9 +40,9 @@ class WEBDATA_EXPORT WebDataServiceBackend
virtual void DBLoaded(sql::InitStatus status) = 0;
};
WebDataServiceBackend(const base::FilePath& path,
Delegate* delegate,
const scoped_refptr<base::MessageLoopProxy>& db_thread);
WebDatabaseBackend(const base::FilePath& path,
Delegate* delegate,
const scoped_refptr<base::MessageLoopProxy>& db_thread);
// Must call only before InitDatabaseWithCallback.
void AddTable(scoped_ptr<WebDatabaseTable> table);
......@@ -66,12 +64,10 @@ class WEBDATA_EXPORT WebDataServiceBackend
// are used in cases where the request is being made from the UI thread and an
// asyncronous callback is required to notify the client of |request|'s
// completion.
void DBWriteTaskWrapper(
const WebDatabaseService::WriteTask& task,
scoped_ptr<WebDataRequest> request);
void DBReadTaskWrapper(
const WebDatabaseService::ReadTask& task,
scoped_ptr<WebDataRequest> request);
void DBWriteTaskWrapper(const WebDatabaseService::WriteTask& task,
scoped_ptr<WebDataRequest> request);
void DBReadTaskWrapper(const WebDatabaseService::ReadTask& task,
scoped_ptr<WebDataRequest> request);
// Task runners to run database tasks.
void ExecuteWriteTask(const WebDatabaseService::WriteTask& task);
......@@ -85,10 +81,10 @@ class WEBDATA_EXPORT WebDataServiceBackend
WebDatabase* database() { return db_.get(); }
protected:
friend class base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend>;
friend class base::DeleteHelper<WebDataServiceBackend>;
friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>;
friend class base::DeleteHelper<WebDatabaseBackend>;
virtual ~WebDataServiceBackend();
virtual ~WebDatabaseBackend();
private:
// Commit the current transaction.
......@@ -123,7 +119,7 @@ class WEBDATA_EXPORT WebDataServiceBackend
// Delegate. See the class definition above for more information.
scoped_ptr<Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend);
DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend);
};
#endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
#endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_
......@@ -8,16 +8,16 @@
#include "base/location.h"
#include "components/webdata/common/web_data_request_manager.h"
#include "components/webdata/common/web_data_results.h"
#include "components/webdata/common/web_data_service_backend.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database_backend.h"
using base::Bind;
using base::FilePath;
// Receives messages from the backend on the DB thread, posts them to
// WebDatabaseService on the UI thread.
class WebDatabaseService::BackendDelegate :
public WebDataServiceBackend::Delegate {
class WebDatabaseService::BackendDelegate
: public WebDatabaseBackend::Delegate {
public:
BackendDelegate(
const base::WeakPtr<WebDatabaseService>& web_database_service)
......@@ -56,19 +56,17 @@ WebDatabaseService::~WebDatabaseService() {
}
void WebDatabaseService::AddTable(scoped_ptr<WebDatabaseTable> table) {
if (!wds_backend_.get()) {
wds_backend_ = new WebDataServiceBackend(
path_, new BackendDelegate(weak_ptr_factory_.GetWeakPtr()),
db_thread_);
if (!web_db_backend_.get()) {
web_db_backend_ = new WebDatabaseBackend(
path_, new BackendDelegate(weak_ptr_factory_.GetWeakPtr()), db_thread_);
}
wds_backend_->AddTable(table.Pass());
web_db_backend_->AddTable(table.Pass());
}
void WebDatabaseService::LoadDatabase() {
DCHECK(wds_backend_.get());
DCHECK(web_db_backend_.get());
db_thread_->PostTask(
FROM_HERE,
Bind(&WebDataServiceBackend::InitDatabase, wds_backend_));
FROM_HERE, Bind(&WebDatabaseBackend::InitDatabase, web_db_backend_));
}
void WebDatabaseService::ShutdownDatabase() {
......@@ -76,30 +74,30 @@ void WebDatabaseService::ShutdownDatabase() {
loaded_callbacks_.clear();
error_callbacks_.clear();
weak_ptr_factory_.InvalidateWeakPtrs();
if (!wds_backend_.get())
if (!web_db_backend_.get())
return;
db_thread_->PostTask(
FROM_HERE, Bind(&WebDataServiceBackend::ShutdownDatabase, wds_backend_));
FROM_HERE, Bind(&WebDatabaseBackend::ShutdownDatabase, web_db_backend_));
}
WebDatabase* WebDatabaseService::GetDatabaseOnDB() const {
DCHECK(db_thread_->BelongsToCurrentThread());
return wds_backend_.get() ? wds_backend_->database() : NULL;
return web_db_backend_.get() ? web_db_backend_->database() : NULL;
}
scoped_refptr<WebDataServiceBackend> WebDatabaseService::GetBackend() const {
return wds_backend_;
scoped_refptr<WebDatabaseBackend> WebDatabaseService::GetBackend() const {
return web_db_backend_;
}
void WebDatabaseService::ScheduleDBTask(
const tracked_objects::Location& from_here,
const WriteTask& task) {
DCHECK(wds_backend_.get());
DCHECK(web_db_backend_.get());
scoped_ptr<WebDataRequest> request(
new WebDataRequest(NULL, wds_backend_->request_manager().get()));
db_thread_->PostTask(from_here,
Bind(&WebDataServiceBackend::DBWriteTaskWrapper,
wds_backend_, task, base::Passed(&request)));
new WebDataRequest(NULL, web_db_backend_->request_manager().get()));
db_thread_->PostTask(
from_here, Bind(&WebDatabaseBackend::DBWriteTaskWrapper, web_db_backend_,
task, base::Passed(&request)));
}
WebDataServiceBase::Handle WebDatabaseService::ScheduleDBTaskWithResult(
......@@ -107,20 +105,20 @@ WebDataServiceBase::Handle WebDatabaseService::ScheduleDBTaskWithResult(
const ReadTask& task,
WebDataServiceConsumer* consumer) {
DCHECK(consumer);
DCHECK(wds_backend_.get());
DCHECK(web_db_backend_.get());
scoped_ptr<WebDataRequest> request(
new WebDataRequest(consumer, wds_backend_->request_manager().get()));
new WebDataRequest(consumer, web_db_backend_->request_manager().get()));
WebDataServiceBase::Handle handle = request->GetHandle();
db_thread_->PostTask(from_here,
Bind(&WebDataServiceBackend::DBReadTaskWrapper,
wds_backend_, task, base::Passed(&request)));
db_thread_->PostTask(
from_here, Bind(&WebDatabaseBackend::DBReadTaskWrapper, web_db_backend_,
task, base::Passed(&request)));
return handle;
}
void WebDatabaseService::CancelRequest(WebDataServiceBase::Handle h) {
if (!wds_backend_.get())
if (!web_db_backend_.get())
return;
wds_backend_->request_manager()->CancelRequest(h);
web_db_backend_->request_manager()->CancelRequest(h);
}
void WebDatabaseService::RegisterDBLoadedCallback(
......
......@@ -23,7 +23,7 @@
#include "components/webdata/common/web_database.h"
#include "components/webdata/common/webdata_export.h"
class WebDataServiceBackend;
class WebDatabaseBackend;
class WebDataRequestManager;
namespace content {
......@@ -77,8 +77,8 @@ class WEBDATA_EXPORT WebDatabaseService
// TODO(caitkp): remove this method once SyncServices no longer depend on it.
virtual WebDatabase* GetDatabaseOnDB() const;
// Returns a pointer to the WebDataServiceBackend.
scoped_refptr<WebDataServiceBackend> GetBackend() const;
// Returns a pointer to the WebDatabaseBackend.
scoped_refptr<WebDatabaseBackend> GetBackend() const;
// Schedule an update/write task on the DB thread.
virtual void ScheduleDBTask(
......@@ -129,7 +129,7 @@ class WEBDATA_EXPORT WebDatabaseService
// The primary owner is |WebDatabaseService| but is refcounted because
// PostTask on DB thread may outlive us.
scoped_refptr<WebDataServiceBackend> wds_backend_;
scoped_refptr<WebDatabaseBackend> web_db_backend_;
// Callbacks to be called once the DB has loaded.
LoadedCallbacks loaded_callbacks_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment