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_BACKGROUND_REQUEST_QUEUE_IN_MEMORY_STORE_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_IN_MEMORY_STORE_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <map> | |
11 | |
12 #include "base/macros.h" | |
13 #include "components/offline_pages/background/request_queue_store.h" | |
14 #include "components/offline_pages/background/save_page_request.h" | |
15 | |
16 namespace offline_pages { | |
17 | |
18 // Interface for classes storing save page requests. | |
19 class RequestQueueInMemoryStore : public RequestQueueStore { | |
20 public: | |
21 enum class TestScenario { | |
22 SUCCESSFUL, | |
23 LOAD_FAILED_RESET_SUCCESS, | |
24 LOAD_FAILED_RESET_FAILED, | |
25 }; | |
26 | |
27 RequestQueueInMemoryStore(); | |
28 explicit RequestQueueInMemoryStore(TestScenario scenario); | |
29 ~RequestQueueInMemoryStore() override; | |
30 | |
31 // RequestQueueStore implementaiton. | |
32 void Initialize(const InitializeCallback& callback) override; | |
33 void GetRequests(const GetRequestsCallback& callback) override; | |
34 void GetRequestsByIds(const std::vector<int64_t>& request_ids, | |
35 const UpdateCallback& callback) override; | |
36 void AddRequest(const SavePageRequest& offline_page, | |
37 const AddCallback& callback) override; | |
38 void UpdateRequests(const std::vector<SavePageRequest>& requests, | |
39 const UpdateCallback& callback) override; | |
40 void RemoveRequests(const std::vector<int64_t>& request_ids, | |
41 const UpdateCallback& callback) override; | |
42 void Reset(const ResetCallback& callback) override; | |
43 StoreState state() const override; | |
44 | |
45 private: | |
46 typedef std::map<int64_t, SavePageRequest> RequestsMap; | |
47 RequestsMap requests_; | |
48 StoreState state_; | |
49 TestScenario scenario_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(RequestQueueInMemoryStore); | |
52 }; | |
53 | |
54 } // namespace offline_pages | |
55 | |
56 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_IN_MEMORY_STORE_H_ | |
OLD | NEW |