Chromium Code Reviews| 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" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 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. | |
| 33 | |
| 32 class WebDataServiceBackend | 34 class WebDataServiceBackend |
| 33 : public base::RefCountedThreadSafe< | 35 : public base::RefCountedThreadSafe< |
| 34 WebDataServiceBackend, | 36 WebDataServiceBackend, |
| 35 content::BrowserThread::DeleteOnDBThread> { | 37 content::BrowserThread::DeleteOnDBThread> { |
| 36 public: | 38 public: |
| 37 class Delegate { | 39 class Delegate { |
| 38 public: | 40 public: |
| 39 virtual ~Delegate() {} | 41 virtual ~Delegate() {} |
| 40 | 42 |
| 41 // Invoked when the backend has finished loading the db. | 43 // Invoked when the backend has finished loading the db. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 55 // Opens the database file from the profile path if an init has not yet been | 57 // Opens the database file from the profile path if an init has not yet been |
| 56 // attempted. Separated from the constructor to ease construction/destruction | 58 // attempted. Separated from the constructor to ease construction/destruction |
| 57 // of this object on one thread but database access on the DB thread. Returns | 59 // of this object on one thread but database access on the DB thread. Returns |
| 58 // the status of the database. | 60 // the status of the database. |
| 59 sql::InitStatus LoadDatabaseIfNecessary(); | 61 sql::InitStatus LoadDatabaseIfNecessary(); |
| 60 | 62 |
| 61 // Shuts down database. |should_reinit| tells us whether or not it should be | 63 // Shuts down database. |should_reinit| tells us whether or not it should be |
| 62 // possible to re-initialize the DB after the shutdown. | 64 // possible to re-initialize the DB after the shutdown. |
| 63 void ShutdownDatabase(bool should_reinit); | 65 void ShutdownDatabase(bool should_reinit); |
| 64 | 66 |
| 65 // Task wrappers to run database tasks. | 67 // Task wrappers to update requests and and notify |request_manager_|. These |
| 68 // are used in cases where the request is being made from the UI thread and an | |
| 69 // asyncronous callback is required to notify the client of |request|'s | |
| 70 // completion. | |
| 66 void DBWriteTaskWrapper( | 71 void DBWriteTaskWrapper( |
| 67 const WebDatabaseService::WriteTask& task, | 72 const WebDatabaseService::WriteTask& task, |
| 68 scoped_ptr<WebDataRequest> request); | 73 scoped_ptr<WebDataRequest> request); |
| 69 void DBReadTaskWrapper( | 74 void DBReadTaskWrapper( |
| 70 const WebDatabaseService::ReadTask& task, | 75 const WebDatabaseService::ReadTask& task, |
| 71 scoped_ptr<WebDataRequest> request); | 76 scoped_ptr<WebDataRequest> request); |
| 72 | 77 |
| 78 // Task runners to run database tasks | |
|
Ilya Sherman
2013/05/10 00:08:00
nit: Please end the sentence with a period.
| |
| 79 void ExecuteWriteTask(const WebDatabaseService::WriteTask& task); | |
| 80 scoped_ptr<WDTypedResult> ExecuteReadTask( | |
| 81 const WebDatabaseService::ReadTask& task); | |
| 82 | |
| 73 const scoped_refptr<WebDataRequestManager>& request_manager() { | 83 const scoped_refptr<WebDataRequestManager>& request_manager() { |
| 74 return request_manager_; | 84 return request_manager_; |
| 75 } | 85 } |
| 76 | 86 |
| 77 WebDatabase* database() { return db_.get(); } | 87 WebDatabase* database() { return db_.get(); } |
| 78 | 88 |
| 79 private: | 89 private: |
| 80 friend struct content::BrowserThread::DeleteOnThread< | 90 friend struct content::BrowserThread::DeleteOnThread< |
| 81 content::BrowserThread::DB>; | 91 content::BrowserThread::DB>; |
| 82 friend class base::DeleteHelper<WebDataServiceBackend>; | 92 friend class base::DeleteHelper<WebDataServiceBackend>; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 112 // fails), used to avoid continually trying to reinit if the db init fails. | 122 // fails), used to avoid continually trying to reinit if the db init fails. |
| 113 bool init_complete_; | 123 bool init_complete_; |
| 114 | 124 |
| 115 // Delegate. See the class definition above for more information. | 125 // Delegate. See the class definition above for more information. |
| 116 scoped_ptr<Delegate> delegate_; | 126 scoped_ptr<Delegate> delegate_; |
| 117 | 127 |
| 118 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); | 128 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); |
| 119 }; | 129 }; |
| 120 | 130 |
| 121 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ | 131 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ |
| OLD | NEW |