| OLD | NEW |
| 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 CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ | 5 #ifndef CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ |
| 6 #define CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ | 6 #define CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Sets the response to checks for a main frame for register attempts. | 75 // Sets the response to checks for a main frame for register attempts. |
| 76 void set_has_main_frame_provider_host(bool value) { | 76 void set_has_main_frame_provider_host(bool value) { |
| 77 has_main_frame_provider_host_ = value; | 77 has_main_frame_provider_host_ = value; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Accessors to internal state | 80 // Accessors to internal state |
| 81 base::Closure delayed_task() const { return delayed_task_; } | 81 base::Closure delayed_task() const { return delayed_task_; } |
| 82 base::TimeDelta delayed_task_delta() const { return delayed_task_delta_; } | 82 base::TimeDelta delayed_task_delta() const { return delayed_task_delta_; } |
| 83 mojom::BackgroundSyncEventLastChance last_chance() const { | 83 blink::mojom::BackgroundSyncEventLastChance last_chance() const { |
| 84 return last_chance_; | 84 return last_chance_; |
| 85 } | 85 } |
| 86 const BackgroundSyncParameters* background_sync_parameters() const { | 86 const BackgroundSyncParameters* background_sync_parameters() const { |
| 87 return parameters_.get(); | 87 return parameters_.get(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 // Override to allow delays to be injected by tests. | 91 // Override to allow delays to be injected by tests. |
| 92 void StoreDataInBackend( | 92 void StoreDataInBackend( |
| 93 int64_t sw_registration_id, | 93 int64_t sw_registration_id, |
| 94 const GURL& origin, | 94 const GURL& origin, |
| 95 const std::string& key, | 95 const std::string& key, |
| 96 const std::string& data, | 96 const std::string& data, |
| 97 const ServiceWorkerStorage::StatusCallback& callback) override; | 97 const ServiceWorkerStorage::StatusCallback& callback) override; |
| 98 | 98 |
| 99 // Override to allow delays to be injected by tests. | 99 // Override to allow delays to be injected by tests. |
| 100 void GetDataFromBackend( | 100 void GetDataFromBackend( |
| 101 const std::string& key, | 101 const std::string& key, |
| 102 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 102 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
| 103 callback) override; | 103 callback) override; |
| 104 | 104 |
| 105 // Override to avoid actual dispatching of the event, just call the provided | 105 // Override to avoid actual dispatching of the event, just call the provided |
| 106 // callback instead. | 106 // callback instead. |
| 107 void DispatchSyncEvent( | 107 void DispatchSyncEvent( |
| 108 const std::string& tag, | 108 const std::string& tag, |
| 109 const scoped_refptr<ServiceWorkerVersion>& active_version, | 109 const scoped_refptr<ServiceWorkerVersion>& active_version, |
| 110 mojom::BackgroundSyncEventLastChance last_chance, | 110 blink::mojom::BackgroundSyncEventLastChance last_chance, |
| 111 const ServiceWorkerVersion::StatusCallback& callback) override; | 111 const ServiceWorkerVersion::StatusCallback& callback) override; |
| 112 | 112 |
| 113 // Override to just store delayed task, and allow tests to control the clock | 113 // Override to just store delayed task, and allow tests to control the clock |
| 114 // and when delayed tasks are executed. | 114 // and when delayed tasks are executed. |
| 115 void ScheduleDelayedTask(const base::Closure& callback, | 115 void ScheduleDelayedTask(const base::Closure& callback, |
| 116 base::TimeDelta delay) override; | 116 base::TimeDelta delay) override; |
| 117 | 117 |
| 118 // Override to avoid actual check for main frame, instead return the value set | 118 // Override to avoid actual check for main frame, instead return the value set |
| 119 // by tests. | 119 // by tests. |
| 120 void HasMainFrameProviderHost(const GURL& origin, | 120 void HasMainFrameProviderHost(const GURL& origin, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 133 // Callback to resume the GetDataFromBackend operation, after explicit delays | 133 // Callback to resume the GetDataFromBackend operation, after explicit delays |
| 134 // injected by tests. | 134 // injected by tests. |
| 135 void GetDataFromBackendContinue( | 135 void GetDataFromBackendContinue( |
| 136 const std::string& key, | 136 const std::string& key, |
| 137 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 137 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
| 138 callback); | 138 callback); |
| 139 | 139 |
| 140 bool corrupt_backend_ = false; | 140 bool corrupt_backend_ = false; |
| 141 bool delay_backend_ = false; | 141 bool delay_backend_ = false; |
| 142 bool has_main_frame_provider_host_ = true; | 142 bool has_main_frame_provider_host_ = true; |
| 143 mojom::BackgroundSyncEventLastChance last_chance_ = | 143 blink::mojom::BackgroundSyncEventLastChance last_chance_ = |
| 144 mojom::BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE; | 144 blink::mojom::BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE; |
| 145 base::Closure continuation_; | 145 base::Closure continuation_; |
| 146 DispatchSyncCallback dispatch_sync_callback_; | 146 DispatchSyncCallback dispatch_sync_callback_; |
| 147 base::Closure delayed_task_; | 147 base::Closure delayed_task_; |
| 148 base::TimeDelta delayed_task_delta_; | 148 base::TimeDelta delayed_task_delta_; |
| 149 | 149 |
| 150 DISALLOW_COPY_AND_ASSIGN(TestBackgroundSyncManager); | 150 DISALLOW_COPY_AND_ASSIGN(TestBackgroundSyncManager); |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 } // namespace content | 153 } // namespace content |
| 154 | 154 |
| 155 #endif // CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ | 155 #endif // CONTENT_TEST_TEST_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |