| Index: components/offline_pages/offline_page_metadata_store_sql.h
|
| diff --git a/components/offline_pages/offline_page_metadata_store_sql.h b/components/offline_pages/offline_page_metadata_store_sql.h
|
| index 8a480293f90bb5f2007b36c79b93d8a606cfc805..d5e2a0c0eb308835abe10c6a1e126aed4729ee13 100644
|
| --- a/components/offline_pages/offline_page_metadata_store_sql.h
|
| +++ b/components/offline_pages/offline_page_metadata_store_sql.h
|
| @@ -34,22 +34,19 @@ class OfflinePageMetadataStoreSQL : public OfflinePageMetadataStore {
|
| ~OfflinePageMetadataStoreSQL() override;
|
|
|
| // Implementation methods.
|
| - void Load(const LoadCallback& callback) override;
|
| + void GetOfflinePages(const LoadCallback& callback) override;
|
| void AddOrUpdateOfflinePage(const OfflinePageItem& offline_page,
|
| const UpdateCallback& callback) override;
|
| void RemoveOfflinePages(const std::vector<int64_t>& offline_ids,
|
| const UpdateCallback& callback) override;
|
| void Reset(const ResetCallback& callback) override;
|
| + StoreState state() const override;
|
|
|
| private:
|
| // Synchronous implementations, these are run on the background thread
|
| // and actually do the work to access SQL. The implementations above
|
| // simply dispatch to the corresponding *Sync method on the background thread.
|
| // 'runner' is where to run the callback.
|
| - static void LoadSync(sql::Connection* db,
|
| - const base::FilePath& path,
|
| - scoped_refptr<base::SingleThreadTaskRunner> runner,
|
| - const LoadCallback& callback);
|
| static void AddOrUpdateOfflinePageSync(
|
| const OfflinePageItem& offline_page,
|
| sql::Connection* db,
|
| @@ -60,15 +57,18 @@ class OfflinePageMetadataStoreSQL : public OfflinePageMetadataStore {
|
| sql::Connection* db,
|
| scoped_refptr<base::SingleThreadTaskRunner> runner,
|
| const UpdateCallback& callback);
|
| - static void ResetSync(std::unique_ptr<sql::Connection> db,
|
| - scoped_refptr<base::SingleThreadTaskRunner> runner,
|
| - const ResetCallback& callback);
|
|
|
| - static void NotifyLoadResult(
|
| - scoped_refptr<base::SingleThreadTaskRunner> runner,
|
| - const LoadCallback& callback,
|
| - LoadStatus status,
|
| - const std::vector<OfflinePageItem>& result);
|
| + // Used to initialize DB connection.
|
| + void OpenConnection();
|
| + void OnOpenConnectionDone(StoreState state);
|
| +
|
| + // Used to reset DB connection.
|
| + void OnResetDone(const ResetCallback& callback, StoreState state);
|
| +
|
| + // Helper function that checks whether a valid DB connection is present.
|
| + // Returns true if valid connection is present, otherwise it returns false and
|
| + // calls the provided callback as a shortcut.
|
| + bool CheckDb(const base::Closure& callback);
|
|
|
| // Background thread where all SQL access should be run.
|
| scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
|
| @@ -77,6 +77,9 @@ class OfflinePageMetadataStoreSQL : public OfflinePageMetadataStore {
|
| base::FilePath db_file_path_;
|
| std::unique_ptr<sql::Connection> db_;
|
|
|
| + StoreState state_;
|
| + base::WeakPtrFactory<OfflinePageMetadataStoreSQL> weak_ptr_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(OfflinePageMetadataStoreSQL);
|
| };
|
|
|
|
|