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 // Chromium settings and storage represent user-selected preferences and | 5 // Chromium settings and storage represent user-selected preferences and |
6 // information and MUST not be extracted, overwritten or modified except | 6 // information and MUST not be extracted, overwritten or modified except |
7 // through Chromium defined APIs. | 7 // through Chromium defined APIs. |
8 | 8 |
9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
11 | 11 |
| 12 #include <memory> |
| 13 |
12 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 17 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
17 #include "base/memory/ref_counted_delete_on_message_loop.h" | 19 #include "base/memory/ref_counted_delete_on_message_loop.h" |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
20 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
22 #include "components/webdata/common/web_data_service_base.h" | 23 #include "components/webdata/common/web_data_service_base.h" |
23 #include "components/webdata/common/web_database.h" | 24 #include "components/webdata/common/web_database.h" |
24 #include "components/webdata/common/webdata_export.h" | 25 #include "components/webdata/common/webdata_export.h" |
25 | 26 |
26 class WebDatabaseBackend; | 27 class WebDatabaseBackend; |
27 class WebDataRequestManager; | 28 class WebDataRequestManager; |
28 | 29 |
(...skipping 13 matching lines...) Expand all Loading... |
42 // | 43 // |
43 // WebDatabaseService defines the interface to a generic data repository | 44 // WebDatabaseService defines the interface to a generic data repository |
44 // responsible for controlling access to the web database (metadata associated | 45 // responsible for controlling access to the web database (metadata associated |
45 // with web pages). | 46 // with web pages). |
46 // | 47 // |
47 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
48 | 49 |
49 class WEBDATA_EXPORT WebDatabaseService | 50 class WEBDATA_EXPORT WebDatabaseService |
50 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 51 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { |
51 public: | 52 public: |
52 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | 53 typedef base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)> ReadTask; |
53 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | 54 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; |
54 | 55 |
55 // Types for managing DB loading callbacks. | 56 // Types for managing DB loading callbacks. |
56 typedef base::Closure DBLoadedCallback; | 57 typedef base::Closure DBLoadedCallback; |
57 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; | 58 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; |
58 | 59 |
59 // Takes the path to the WebDatabase file. | 60 // Takes the path to the WebDatabase file. |
60 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. | 61 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. |
61 WebDatabaseService(const base::FilePath& path, | 62 WebDatabaseService(const base::FilePath& path, |
62 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, | 63 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
63 scoped_refptr<base::SingleThreadTaskRunner> db_thread); | 64 scoped_refptr<base::SingleThreadTaskRunner> db_thread); |
64 | 65 |
65 // Adds |table| as a WebDatabaseTable that will participate in | 66 // Adds |table| as a WebDatabaseTable that will participate in |
66 // managing the database, transferring ownership. All calls to this | 67 // managing the database, transferring ownership. All calls to this |
67 // method must be made before |LoadDatabase| is called. | 68 // method must be made before |LoadDatabase| is called. |
68 virtual void AddTable(scoped_ptr<WebDatabaseTable> table); | 69 virtual void AddTable(std::unique_ptr<WebDatabaseTable> table); |
69 | 70 |
70 // Initializes the web database service. | 71 // Initializes the web database service. |
71 virtual void LoadDatabase(); | 72 virtual void LoadDatabase(); |
72 | 73 |
73 // Unloads the database and shuts down the service. | 74 // Unloads the database and shuts down the service. |
74 virtual void ShutdownDatabase(); | 75 virtual void ShutdownDatabase(); |
75 | 76 |
76 // Gets a pointer to the WebDatabase (owned by WebDatabaseService). | 77 // Gets a pointer to the WebDatabase (owned by WebDatabaseService). |
77 // TODO(caitkp): remove this method once SyncServices no longer depend on it. | 78 // TODO(caitkp): remove this method once SyncServices no longer depend on it. |
78 virtual WebDatabase* GetDatabaseOnDB() const; | 79 virtual WebDatabase* GetDatabaseOnDB() const; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 143 |
143 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 144 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
144 | 145 |
145 // All vended weak pointers are invalidated in ShutdownDatabase(). | 146 // All vended weak pointers are invalidated in ShutdownDatabase(). |
146 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 147 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
147 | 148 |
148 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); | 149 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); |
149 }; | 150 }; |
150 | 151 |
151 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 152 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
OLD | NEW |