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

Side by Side Diff: content/browser/background_fetch/background_fetch_context.h

Issue 2777183002: Hook up the other Background Fetch Mojo methods with the system (Closed)
Patch Set: Hook up the other Background Fetch Mojo methods with the system Created 3 years, 8 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
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 8 #include <map>
9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h" 16 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h"
16 17
18 namespace url {
19 class Origin;
20 }
21
17 namespace content { 22 namespace content {
18 23
19 class BackgroundFetchDataManager; 24 class BackgroundFetchDataManager;
20 class BackgroundFetchJobController; 25 class BackgroundFetchJobController;
21 struct BackgroundFetchOptions; 26 struct BackgroundFetchOptions;
22 class BackgroundFetchRegistrationId; 27 class BackgroundFetchRegistrationId;
23 class BrowserContext; 28 class BrowserContext;
24 class ServiceWorkerContextWrapper; 29 class ServiceWorkerContextWrapper;
25 struct ServiceWorkerFetchRequest; 30 struct ServiceWorkerFetchRequest;
26 class StoragePartitionImpl; 31 class StoragePartitionImpl;
(...skipping 18 matching lines...) Expand all
45 50
46 // Starts a Background Fetch for the |registration_id|. The |requests| will be 51 // Starts a Background Fetch for the |registration_id|. The |requests| will be
47 // asynchronously fetched. The |callback| will be invoked when the fetch has 52 // asynchronously fetched. The |callback| will be invoked when the fetch has
48 // been registered, or an error occurred that avoids it from doing so. 53 // been registered, or an error occurred that avoids it from doing so.
49 void StartFetch( 54 void StartFetch(
50 const BackgroundFetchRegistrationId& registration_id, 55 const BackgroundFetchRegistrationId& registration_id,
51 const std::vector<ServiceWorkerFetchRequest>& requests, 56 const std::vector<ServiceWorkerFetchRequest>& requests,
52 const BackgroundFetchOptions& options, 57 const BackgroundFetchOptions& options,
53 const blink::mojom::BackgroundFetchService::FetchCallback& callback); 58 const blink::mojom::BackgroundFetchService::FetchCallback& callback);
54 59
60 // Returns a vector with the tags of the active fetches for the given |origin|
61 // and |service_worker_registration_id|.
62 std::vector<std::string> GetActiveTagsForServiceWorkerRegistration(
63 int64_t service_worker_registration_id,
64 const url::Origin& origin) const;
65
66 // Returns the JobController that is handling the |registration_id|, or a
67 // nullptr if it does not exist. Must be immediately used by the caller.
68 BackgroundFetchJobController* GetActiveFetch(
69 const BackgroundFetchRegistrationId& registration_id) const;
70
55 private: 71 private:
56 friend class base::DeleteHelper<BackgroundFetchContext>; 72 friend class base::DeleteHelper<BackgroundFetchContext>;
57 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 73 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
58 friend class base::RefCountedThreadSafe<BackgroundFetchContext, 74 friend class base::RefCountedThreadSafe<BackgroundFetchContext,
59 BrowserThread::DeleteOnUIThread>; 75 BrowserThread::DeleteOnUIThread>;
60 76
61 ~BackgroundFetchContext(); 77 ~BackgroundFetchContext();
62 78
63 // Shuts down the active Job Controllers on the IO thread. 79 // Shuts down the active Job Controllers on the IO thread.
64 void ShutdownOnIO(); 80 void ShutdownOnIO();
65 81
66 // Creates a new Job Controller for the given |registration_id| and |options|, 82 // Creates a new Job Controller for the given |registration_id| and |options|,
67 // which will start fetching the files that are part of the registration. 83 // which will start fetching the files that are part of the registration.
68 void CreateController(const BackgroundFetchRegistrationId& registration_id, 84 void CreateController(const BackgroundFetchRegistrationId& registration_id,
69 const BackgroundFetchOptions& options); 85 const BackgroundFetchOptions& options);
70 86
71 // Called when a new registration has been created by the data manager. 87 // Called when a new registration has been created by the data manager.
72 void DidCreateRegistration( 88 void DidCreateRegistration(
73 const BackgroundFetchRegistrationId& registration_id, 89 const BackgroundFetchRegistrationId& registration_id,
74 const BackgroundFetchOptions& options, 90 const BackgroundFetchOptions& options,
75 const blink::mojom::BackgroundFetchService::FetchCallback& callback, 91 const blink::mojom::BackgroundFetchService::FetchCallback& callback,
76 blink::mojom::BackgroundFetchError error); 92 blink::mojom::BackgroundFetchError error);
77 93
78 // Called when a Job Controller has finished processing a Background Fetch 94 // Called when a Job Controller has finished processing a Background Fetch
79 // registration, as identified by |registration_id|. 95 // registration, as identified by |registration_id|. |aborted_by_developer|
80 void DidFinishFetch(const BackgroundFetchRegistrationId& registration_id); 96 // will be set to true when it finished at the developer's request.
97 void DidFinishFetch(const BackgroundFetchRegistrationId& registration_id,
98 bool aborted_by_developer);
81 99
82 // |this| is owned by the BrowserContext via the StoragePartitionImpl. 100 // |this| is owned by the BrowserContext via the StoragePartitionImpl.
83 BrowserContext* browser_context_; 101 BrowserContext* browser_context_;
84 StoragePartitionImpl* storage_partition_; 102 StoragePartitionImpl* storage_partition_;
85 103
86 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 104 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
87 std::unique_ptr<BackgroundFetchDataManager> background_fetch_data_manager_; 105 std::unique_ptr<BackgroundFetchDataManager> background_fetch_data_manager_;
88 106
89 // Map of the Background Fetch fetches that are currently in-progress. 107 // Map of the Background Fetch fetches that are currently in-progress.
90 std::map<BackgroundFetchRegistrationId, 108 std::map<BackgroundFetchRegistrationId,
91 std::unique_ptr<BackgroundFetchJobController>> 109 std::unique_ptr<BackgroundFetchJobController>>
92 active_fetches_; 110 active_fetches_;
93 111
94 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); 112 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext);
95 }; 113 };
96 114
97 } // namespace content 115 } // namespace content
98 116
99 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ 117 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/background_fetch/background_fetch_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698