Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: components/offline_pages/offline_page_model_impl.h

Issue 2340133005: Merge M54: Support serving offline page by offline ID (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_IMPL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/gtest_prod_util.h" 19 #include "base/gtest_prod_util.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/memory/scoped_vector.h" 22 #include "base/memory/scoped_vector.h"
23 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
24 #include "base/observer_list.h" 24 #include "base/observer_list.h"
25 #include "base/optional.h" 25 #include "base/optional.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/time/time.h"
27 #include "components/keyed_service/core/keyed_service.h" 28 #include "components/keyed_service/core/keyed_service.h"
28 #include "components/offline_pages/offline_page_archiver.h" 29 #include "components/offline_pages/offline_page_archiver.h"
29 #include "components/offline_pages/offline_page_metadata_store.h" 30 #include "components/offline_pages/offline_page_metadata_store.h"
30 #include "components/offline_pages/offline_page_model.h" 31 #include "components/offline_pages/offline_page_model.h"
31 #include "components/offline_pages/offline_page_model_event_logger.h" 32 #include "components/offline_pages/offline_page_model_event_logger.h"
32 #include "components/offline_pages/offline_page_storage_manager.h" 33 #include "components/offline_pages/offline_page_storage_manager.h"
33 #include "components/offline_pages/offline_page_types.h" 34 #include "components/offline_pages/offline_page_types.h"
34 35
35 class GURL; 36 class GURL;
36 namespace base { 37 namespace base {
38 class Clock;
37 class SequencedTaskRunner; 39 class SequencedTaskRunner;
38 class Time;
39 class TimeDelta; 40 class TimeDelta;
40 class TimeTicks; 41 class TimeTicks;
41 } // namespace base 42 } // namespace base
42 43
43 namespace offline_pages { 44 namespace offline_pages {
44 45
45 static const int64_t kInvalidOfflineId = 0; 46 static const int64_t kInvalidOfflineId = 0;
46 47
47 struct ClientId; 48 struct ClientId;
48 struct OfflinePageItem; 49 struct OfflinePageItem;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const OfflinePageItem* MaybeGetBestPageForOnlineURL( 108 const OfflinePageItem* MaybeGetBestPageForOnlineURL(
108 const GURL& online_url) const override; 109 const GURL& online_url) const override;
109 void CheckMetadataConsistency() override; 110 void CheckMetadataConsistency() override;
110 void ExpirePages(const std::vector<int64_t>& offline_ids, 111 void ExpirePages(const std::vector<int64_t>& offline_ids,
111 const base::Time& expiration_time, 112 const base::Time& expiration_time,
112 const base::Callback<void(bool)>& callback) override; 113 const base::Callback<void(bool)>& callback) override;
113 ClientPolicyController* GetPolicyController() override; 114 ClientPolicyController* GetPolicyController() override;
114 115
115 // Methods for testing only: 116 // Methods for testing only:
116 OfflinePageMetadataStore* GetStoreForTesting(); 117 OfflinePageMetadataStore* GetStoreForTesting();
118 void set_testing_clock(base::Clock* clock) { testing_clock_ = clock; }
117 119
118 OfflinePageStorageManager* GetStorageManager(); 120 OfflinePageStorageManager* GetStorageManager();
119 121
120 bool is_loaded() const override; 122 bool is_loaded() const override;
121 123
122 OfflineEventLogger* GetLogger() override; 124 OfflineEventLogger* GetLogger() override;
123 125
124 protected: 126 protected:
125 // Adding a protected constructor for testing-only purposes in 127 // Adding a protected constructor for testing-only purposes in
126 // offline_page_storage_manager_unittest.cc 128 // offline_page_storage_manager_unittest.cc
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 OfflinePageStorageManager::ClearStorageResult result); 262 OfflinePageStorageManager::ClearStorageResult result);
261 263
262 // Post task to clear storage. 264 // Post task to clear storage.
263 void PostClearStorageIfNeededTask(); 265 void PostClearStorageIfNeededTask();
264 266
265 // Check if |offline_page| is user-requested. 267 // Check if |offline_page| is user-requested.
266 bool IsUserRequestedPage(const OfflinePageItem& offline_page) const; 268 bool IsUserRequestedPage(const OfflinePageItem& offline_page) const;
267 269
268 void RunWhenLoaded(const base::Closure& job); 270 void RunWhenLoaded(const base::Closure& job);
269 271
272 base::Time GetCurrentTime() const;
273
270 // Persistent store for offline page metadata. 274 // Persistent store for offline page metadata.
271 std::unique_ptr<OfflinePageMetadataStore> store_; 275 std::unique_ptr<OfflinePageMetadataStore> store_;
272 276
273 // Location where all of the archive files will be stored. 277 // Location where all of the archive files will be stored.
274 base::FilePath archives_dir_; 278 base::FilePath archives_dir_;
275 279
276 // The observers. 280 // The observers.
277 base::ObserverList<Observer> observers_; 281 base::ObserverList<Observer> observers_;
278 282
279 bool is_loaded_; 283 bool is_loaded_;
(...skipping 13 matching lines...) Expand all
293 // Manager for the storage consumed by archives and responsible for 297 // Manager for the storage consumed by archives and responsible for
294 // automatic page clearing. 298 // automatic page clearing.
295 std::unique_ptr<OfflinePageStorageManager> storage_manager_; 299 std::unique_ptr<OfflinePageStorageManager> storage_manager_;
296 300
297 // Manager for the offline archive files and directory. 301 // Manager for the offline archive files and directory.
298 std::unique_ptr<ArchiveManager> archive_manager_; 302 std::unique_ptr<ArchiveManager> archive_manager_;
299 303
300 // Logger to facilitate recording of events. 304 // Logger to facilitate recording of events.
301 OfflinePageModelEventLogger offline_event_logger_; 305 OfflinePageModelEventLogger offline_event_logger_;
302 306
307 // Clock for getting time in testing code. The setter is responsible to reset
308 // it once it is not longer needed.
309 base::Clock* testing_clock_;
310
303 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; 311 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_;
304 312
305 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); 313 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl);
306 }; 314 };
307 315
308 } // namespace offline_pages 316 } // namespace offline_pages
309 317
310 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 318 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
OLDNEW
« no previous file with comments | « components/offline_pages/downloads/download_ui_adapter.cc ('k') | components/offline_pages/offline_page_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698