| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/supports_user_data.h" | 24 #include "base/supports_user_data.h" |
| 25 #include "components/keyed_service/core/keyed_service.h" | 25 #include "components/keyed_service/core/keyed_service.h" |
| 26 #include "components/offline_pages/offline_page_archiver.h" | 26 #include "components/offline_pages/offline_page_archiver.h" |
| 27 #include "components/offline_pages/offline_page_metadata_store.h" | 27 #include "components/offline_pages/offline_page_metadata_store.h" |
| 28 | 28 |
| 29 class GURL; | 29 class GURL; |
| 30 namespace base { | 30 namespace base { |
| 31 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
| 32 class Time; | 32 class Time; |
| 33 class TimeDelta; | 33 class TimeDelta; |
| 34 class TimeTicks; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace offline_pages { | 37 namespace offline_pages { |
| 37 | 38 |
| 38 static const char* const kBookmarkNamespace = "bookmark"; | 39 static const char* const kBookmarkNamespace = "bookmark"; |
| 39 static const int64_t kInvalidOfflineId = 0; | 40 static const int64_t kInvalidOfflineId = 0; |
| 40 | 41 |
| 41 struct ClientId; | 42 struct ClientId; |
| 42 | 43 |
| 43 struct OfflinePageItem; | 44 struct OfflinePageItem; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 OfflinePageMetadataStore* GetStoreForTesting(); | 262 OfflinePageMetadataStore* GetStoreForTesting(); |
| 262 | 263 |
| 263 bool is_loaded() const { return is_loaded_; } | 264 bool is_loaded() const { return is_loaded_; } |
| 264 | 265 |
| 265 private: | 266 private: |
| 266 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion); | 267 FRIEND_TEST_ALL_PREFIXES(OfflinePageModelTest, MarkPageForDeletion); |
| 267 | 268 |
| 268 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; | 269 typedef ScopedVector<OfflinePageArchiver> PendingArchivers; |
| 269 | 270 |
| 270 // Callback for ensuring archive directory is created. | 271 // Callback for ensuring archive directory is created. |
| 271 void OnEnsureArchivesDirCreatedDone(); | 272 void OnEnsureArchivesDirCreatedDone(const base::TimeTicks& start_time); |
| 272 | 273 |
| 273 void GetAllPagesAfterLoadDone( | 274 void GetAllPagesAfterLoadDone( |
| 274 const MultipleOfflinePageItemCallback& callback); | 275 const MultipleOfflinePageItemCallback& callback); |
| 275 void CheckPagesExistOfflineAfterLoadDone( | 276 void CheckPagesExistOfflineAfterLoadDone( |
| 276 const std::set<GURL>& urls, | 277 const std::set<GURL>& urls, |
| 277 const CheckPagesExistOfflineCallback& callback); | 278 const CheckPagesExistOfflineCallback& callback); |
| 278 void GetOfflineIdsForClientIdWhenLoadDone( | 279 void GetOfflineIdsForClientIdWhenLoadDone( |
| 279 const ClientId& client_id, | 280 const ClientId& client_id, |
| 280 const MultipleOfflineIdCallback& callback) const; | 281 const MultipleOfflineIdCallback& callback) const; |
| 281 void GetPageByOfflineIdWhenLoadDone( | 282 void GetPageByOfflineIdWhenLoadDone( |
| 282 int64_t offline_id, | 283 int64_t offline_id, |
| 283 const SingleOfflinePageItemCallback& callback) const; | 284 const SingleOfflinePageItemCallback& callback) const; |
| 284 void GetPagesByOnlineURLWhenLoadDone( | 285 void GetPagesByOnlineURLWhenLoadDone( |
| 285 const GURL& offline_url, | 286 const GURL& offline_url, |
| 286 const MultipleOfflinePageItemCallback& callback) const; | 287 const MultipleOfflinePageItemCallback& callback) const; |
| 287 void GetPageByOfflineURLWhenLoadDone( | 288 void GetPageByOfflineURLWhenLoadDone( |
| 288 const GURL& offline_url, | 289 const GURL& offline_url, |
| 289 const SingleOfflinePageItemCallback& callback) const; | 290 const SingleOfflinePageItemCallback& callback) const; |
| 290 | 291 |
| 291 // Callback for checking whether we have offline pages. | 292 // Callback for checking whether we have offline pages. |
| 292 void HasPagesAfterLoadDone(const std::string& name_space, | 293 void HasPagesAfterLoadDone(const std::string& name_space, |
| 293 const HasPagesCallback& callback) const; | 294 const HasPagesCallback& callback) const; |
| 294 | 295 |
| 295 // Callback for loading pages from the offline page metadata store. | 296 // Callback for loading pages from the offline page metadata store. |
| 296 void OnLoadDone(OfflinePageMetadataStore::LoadStatus load_status, | 297 void OnLoadDone(const base::TimeTicks& start_time, |
| 298 OfflinePageMetadataStore::LoadStatus load_status, |
| 297 const std::vector<OfflinePageItem>& offline_pages); | 299 const std::vector<OfflinePageItem>& offline_pages); |
| 298 | 300 |
| 299 // Steps for saving a page offline. | 301 // Steps for saving a page offline. |
| 300 void OnCreateArchiveDone(const GURL& requested_url, | 302 void OnCreateArchiveDone(const GURL& requested_url, |
| 301 int64_t offline_id, | 303 int64_t offline_id, |
| 302 const ClientId& client_id, | 304 const ClientId& client_id, |
| 303 const base::Time& start_time, | 305 const base::Time& start_time, |
| 304 const SavePageCallback& callback, | 306 const SavePageCallback& callback, |
| 305 OfflinePageArchiver* archiver, | 307 OfflinePageArchiver* archiver, |
| 306 OfflinePageArchiver::ArchiverResult result, | 308 OfflinePageArchiver::ArchiverResult result, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 std::vector<base::Closure> delayed_tasks_; | 384 std::vector<base::Closure> delayed_tasks_; |
| 383 | 385 |
| 384 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 386 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 385 | 387 |
| 386 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 388 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 387 }; | 389 }; |
| 388 | 390 |
| 389 } // namespace offline_pages | 391 } // namespace offline_pages |
| 390 | 392 |
| 391 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 393 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |