| 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_DATABASE_BACKEND_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/ref_counted_delete_on_message_loop.h" | 15 #include "base/memory/ref_counted_delete_on_sequence.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "components/webdata/common/web_database_service.h" | 18 #include "components/webdata/common/web_database_service.h" |
| 19 #include "components/webdata/common/webdata_export.h" | 19 #include "components/webdata/common/webdata_export.h" |
| 20 | 20 |
| 21 class WebDatabase; | 21 class WebDatabase; |
| 22 class WebDatabaseTable; | 22 class WebDatabaseTable; |
| 23 class WebDataRequest; | 23 class WebDataRequest; |
| 24 class WebDataRequestManager; | 24 class WebDataRequestManager; |
| 25 | 25 |
| 26 // WebDatabaseBackend handles all database tasks posted by | 26 // WebDatabaseBackend handles all database tasks posted by |
| 27 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the | 27 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the |
| 28 // DB thread. | 28 // DB thread. |
| 29 | 29 |
| 30 class WEBDATA_EXPORT WebDatabaseBackend | 30 class WEBDATA_EXPORT WebDatabaseBackend |
| 31 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend> { | 31 : public base::RefCountedDeleteOnSequence<WebDatabaseBackend> { |
| 32 public: | 32 public: |
| 33 class Delegate { | 33 class Delegate { |
| 34 public: | 34 public: |
| 35 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
| 36 | 36 |
| 37 // Invoked when the backend has finished loading the db. | 37 // Invoked when the backend has finished loading the db. |
| 38 // |status| is the result of initializing the db. | 38 // |status| is the result of initializing the db. |
| 39 // |diagnostics| contains diagnostic information about the db, and it will | 39 // |diagnostics| contains diagnostic information about the db, and it will |
| 40 // only be populated when an error occurs. | 40 // only be populated when an error occurs. |
| 41 virtual void DBLoaded(sql::InitStatus status, | 41 virtual void DBLoaded(sql::InitStatus status, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 71 std::unique_ptr<WDTypedResult> ExecuteReadTask( | 71 std::unique_ptr<WDTypedResult> ExecuteReadTask( |
| 72 const WebDatabaseService::ReadTask& task); | 72 const WebDatabaseService::ReadTask& task); |
| 73 | 73 |
| 74 const scoped_refptr<WebDataRequestManager>& request_manager() { | 74 const scoped_refptr<WebDataRequestManager>& request_manager() { |
| 75 return request_manager_; | 75 return request_manager_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 WebDatabase* database() { return db_.get(); } | 78 WebDatabase* database() { return db_.get(); } |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>; | 81 friend class base::RefCountedDeleteOnSequence<WebDatabaseBackend>; |
| 82 friend class base::DeleteHelper<WebDatabaseBackend>; | 82 friend class base::DeleteHelper<WebDatabaseBackend>; |
| 83 | 83 |
| 84 virtual ~WebDatabaseBackend(); | 84 virtual ~WebDatabaseBackend(); |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 // Opens the database file from the profile path if an init has not yet been | 87 // Opens the database file from the profile path if an init has not yet been |
| 88 // attempted. Separated from the constructor to ease construction/destruction | 88 // attempted. Separated from the constructor to ease construction/destruction |
| 89 // of this object on one thread but database access on the DB thread. | 89 // of this object on one thread but database access on the DB thread. |
| 90 void LoadDatabaseIfNecessary(); | 90 void LoadDatabaseIfNecessary(); |
| 91 | 91 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // diagnostic information. | 129 // diagnostic information. |
| 130 std::string diagnostics_; | 130 std::string diagnostics_; |
| 131 | 131 |
| 132 // Delegate. See the class definition above for more information. | 132 // Delegate. See the class definition above for more information. |
| 133 std::unique_ptr<Delegate> delegate_; | 133 std::unique_ptr<Delegate> delegate_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); | 135 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 138 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| OLD | NEW |