Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 StoragePartition* storage_partition, | 34 StoragePartition* storage_partition, |
| 35 const scoped_refptr<ServiceWorkerContextWrapper>& context); | 35 const scoped_refptr<ServiceWorkerContextWrapper>& context); |
| 36 | 36 |
| 37 // Init and Shutdown are for use on the UI thread when the StoragePartition is | 37 // Init and Shutdown are for use on the UI thread when the StoragePartition is |
| 38 // being setup and torn down. | 38 // being setup and torn down. |
| 39 void Init(); | 39 void Init(); |
| 40 | 40 |
| 41 // Shutdown must be called before deleting this. Call on the UI thread. | 41 // Shutdown must be called before deleting this. Call on the UI thread. |
| 42 void Shutdown(); | 42 void Shutdown(); |
| 43 | 43 |
| 44 // Called by the JobController to inform the context that the job is complete. | |
| 45 // TODO(harkness): Pass back enough information that the context can construct | |
| 46 // the Mojo response. | |
| 47 void JobComplete(const std::string& job_guid); | |
|
Peter Beverloo
2017/03/08 14:58:19
Could we instead give the JobController a base::ca
harkness
2017/03/10 13:33:53
I agree with using callbacks, but this hadn't been
| |
| 48 | |
| 44 BackgroundFetchDataManager* GetDataManagerForTesting() { | 49 BackgroundFetchDataManager* GetDataManagerForTesting() { |
| 45 return &background_fetch_data_manager_; | 50 return &background_fetch_data_manager_; |
| 46 } | 51 } |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 void CreateRequest(const BackgroundFetchJobInfo& job_info, | 54 void CreateRequest(const BackgroundFetchJobInfo& job_info, |
| 50 std::vector<BackgroundFetchRequestInfo>& request_infos); | 55 std::vector<BackgroundFetchRequestInfo>& request_infos); |
| 51 | 56 |
| 52 void ShutdownOnIO(); | 57 void ShutdownOnIO(); |
| 53 | 58 |
| 54 friend class base::RefCountedThreadSafe<BackgroundFetchContext>; | 59 friend class base::RefCountedThreadSafe<BackgroundFetchContext>; |
| 55 ~BackgroundFetchContext(); | 60 ~BackgroundFetchContext(); |
| 56 | 61 |
| 57 // The Context is owned by the BrowserContext via the StoragePartition. | 62 // The Context is owned by the BrowserContext via the StoragePartition. |
| 58 BrowserContext* browser_context_; | 63 BrowserContext* browser_context_; |
| 59 StoragePartition* storage_partition_; | 64 StoragePartition* storage_partition_; |
| 60 | 65 |
| 61 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 66 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 62 BackgroundFetchDataManager background_fetch_data_manager_; | 67 BackgroundFetchDataManager background_fetch_data_manager_; |
| 63 | 68 |
| 64 std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobController>> | 69 std::unordered_map<std::string, std::unique_ptr<BackgroundFetchJobController>> |
| 65 job_map_; | 70 job_map_; |
| 66 | 71 |
| 67 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | 72 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
| 68 }; | 73 }; |
| 69 | 74 |
| 70 } // namespace content | 75 } // namespace content |
| 71 | 76 |
| 72 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 77 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| OLD | NEW |