Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_ | |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
|
fgorski
2016/03/24 16:27:56
are you using this include?
bburns
2016/03/25 23:07:38
removed.
| |
| 13 #include "base/files/file_path.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "components/offline_pages/offline_page_metadata_store.h" | |
| 16 | |
| 17 namespace sql { | |
| 18 class Connection; | |
| 19 class MetaTable; | |
| 20 class Statement; | |
| 21 class StatementID; | |
| 22 } | |
| 23 | |
| 24 namespace base { | |
| 25 class SequencedTaskRunner; | |
| 26 } | |
| 27 | |
| 28 namespace offline_pages { | |
| 29 | |
| 30 // OfflinePageMetadataStoreSQL is an instance of OfflinePageMetadataStore | |
| 31 // which is implemented using a SQLite database. | |
| 32 class OfflinePageMetadataStoreSQL : public OfflinePageMetadataStore { | |
| 33 public: | |
| 34 OfflinePageMetadataStoreSQL( | |
| 35 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | |
| 36 const base::FilePath& database_dir); | |
| 37 virtual ~OfflinePageMetadataStoreSQL(); | |
| 38 | |
| 39 // Implementation methods | |
| 40 virtual void Load(const LoadCallback& callback); | |
| 41 virtual void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page, | |
| 42 const UpdateCallback& callback); | |
| 43 virtual void RemoveOfflinePages(const std::vector<int64_t>& offline_ids, | |
| 44 const UpdateCallback& callback); | |
| 45 virtual void Reset(const ResetCallback& callback); | |
| 46 | |
| 47 private: | |
| 48 // Synchronous implementations | |
|
fgorski
2016/03/24 16:27:55
Please explain the comment in more details.
Consi
bburns
2016/03/25 23:07:38
Done (well, I explained the sync/threading stuff)
| |
| 49 void LoadSync(const LoadCallback& callback); | |
| 50 void AddOrUpdateOfflinePageSync(const OfflinePageItem& offline_page, | |
| 51 const UpdateCallback& callback); | |
| 52 void RemoveOfflinePagesSync(const std::vector<int64_t>& offline_ids, | |
| 53 const UpdateCallback& callback); | |
| 54 | |
| 55 void NotifyLoadResult(const LoadCallback& callback, | |
| 56 LoadStatus status, | |
| 57 const std::vector<OfflinePageItem>& result); | |
| 58 | |
|
fgorski
2016/03/24 16:27:55
Please document the fields with respect to their p
bburns
2016/03/25 23:07:38
Done.
| |
| 59 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; | |
| 60 base::FilePath db_file_path_; | |
| 61 base::WeakPtrFactory<OfflinePageMetadataStoreSQL> weak_ptr_factory_; | |
|
fgorski
2016/03/24 16:27:55
From weak_ptr.h:
// Member variables should appear
bburns
2016/03/25 23:07:38
Done.
| |
| 62 | |
| 63 scoped_ptr<sql::Connection> db_; | |
|
fgorski
2016/03/24 16:27:55
include base/memory/scoped_ptr.h
bburns
2016/03/25 23:07:38
Done.
| |
| 64 scoped_ptr<sql::MetaTable> meta_table_; | |
| 65 | |
| 66 // only useful for testing | |
|
Dmitry Titov
2016/03/24 23:22:20
don't see anything modifying or initializing this.
bburns
2016/03/25 23:07:38
Now that there are tests, its used.
| |
| 67 bool use_in_memory_; | |
| 68 }; | |
|
fgorski
2016/03/24 16:27:55
DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreS
bburns
2016/03/25 23:07:38
Done.
| |
| 69 | |
| 70 } // namespace offline_pages | |
| 71 | |
| 72 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_SQL_H_ | |
| OLD | NEW |