| OLD | NEW |
| 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 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ |
| 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/ref_counted_delete_on_message_loop.h" | 13 #include "base/memory/ref_counted_delete_on_task_runner.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "components/webdata/common/web_database_service.h" | 16 #include "components/webdata/common/web_database_service.h" |
| 17 #include "components/webdata/common/webdata_export.h" | 17 #include "components/webdata/common/webdata_export.h" |
| 18 | 18 |
| 19 class WebDatabase; | 19 class WebDatabase; |
| 20 class WebDatabaseTable; | 20 class WebDatabaseTable; |
| 21 class WebDataRequest; | 21 class WebDataRequest; |
| 22 class WebDataRequestManager; | 22 class WebDataRequestManager; |
| 23 | 23 |
| 24 namespace tracked_objects { | 24 namespace tracked_objects { |
| 25 class Location; | 25 class Location; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // WebDataServiceBackend handles all database tasks posted by | 28 // WebDataServiceBackend handles all database tasks posted by |
| 29 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the | 29 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the |
| 30 // DB thread. | 30 // DB thread. |
| 31 | 31 |
| 32 // TODO(caitkp): Rename this class to WebDatabaseBackend. | 32 // TODO(caitkp): Rename this class to WebDatabaseBackend. |
| 33 | 33 |
| 34 class WEBDATA_EXPORT WebDataServiceBackend | 34 class WEBDATA_EXPORT WebDataServiceBackend |
| 35 : public base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend> { | 35 : public base::RefCountedDeleteOnTaskRunner<WebDataServiceBackend> { |
| 36 public: | 36 public: |
| 37 class Delegate { | 37 class Delegate { |
| 38 public: | 38 public: |
| 39 virtual ~Delegate() {} | 39 virtual ~Delegate() {} |
| 40 | 40 |
| 41 // Invoked when the backend has finished loading the db. | 41 // Invoked when the backend has finished loading the db. |
| 42 virtual void DBLoaded(sql::InitStatus status) = 0; | 42 virtual void DBLoaded(sql::InitStatus status) = 0; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 WebDataServiceBackend(const base::FilePath& path, | 45 WebDataServiceBackend(const base::FilePath& path, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 scoped_ptr<WDTypedResult> ExecuteReadTask( | 78 scoped_ptr<WDTypedResult> ExecuteReadTask( |
| 79 const WebDatabaseService::ReadTask& task); | 79 const WebDatabaseService::ReadTask& task); |
| 80 | 80 |
| 81 const scoped_refptr<WebDataRequestManager>& request_manager() { | 81 const scoped_refptr<WebDataRequestManager>& request_manager() { |
| 82 return request_manager_; | 82 return request_manager_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 WebDatabase* database() { return db_.get(); } | 85 WebDatabase* database() { return db_.get(); } |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 friend class base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend>; | 88 friend class base::RefCountedDeleteOnTaskRunner<WebDataServiceBackend>; |
| 89 friend class base::DeleteHelper<WebDataServiceBackend>; | 89 friend class base::DeleteHelper<WebDataServiceBackend>; |
| 90 | 90 |
| 91 virtual ~WebDataServiceBackend(); | 91 virtual ~WebDataServiceBackend(); |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // Commit the current transaction. | 94 // Commit the current transaction. |
| 95 void Commit(); | 95 void Commit(); |
| 96 | 96 |
| 97 // Path to database file. | 97 // Path to database file. |
| 98 base::FilePath db_path_; | 98 base::FilePath db_path_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 120 // fails), used to avoid continually trying to reinit if the db init fails. | 120 // fails), used to avoid continually trying to reinit if the db init fails. |
| 121 bool init_complete_; | 121 bool init_complete_; |
| 122 | 122 |
| 123 // Delegate. See the class definition above for more information. | 123 // Delegate. See the class definition above for more information. |
| 124 scoped_ptr<Delegate> delegate_; | 124 scoped_ptr<Delegate> delegate_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); | 126 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ | 129 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ |
| OLD | NEW |