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

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

Issue 2774343002: Hook up BackgroundFetchServiceImpl::Fetch() to start a fetch (Closed)
Patch Set: rebase 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
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_SERVICE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_SERVICE_IMPL_H_ 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_SERVICE_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h" 15 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h"
15 16
16 namespace url { 17 namespace url {
17 class Origin; 18 class Origin;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class BackgroundFetchContext; 23 class BackgroundFetchContext;
23 struct BackgroundFetchOptions; 24 struct BackgroundFetchOptions;
24 class ServiceWorkerContextWrapper;
25 25
26 class BackgroundFetchServiceImpl : public blink::mojom::BackgroundFetchService { 26 class BackgroundFetchServiceImpl : public blink::mojom::BackgroundFetchService {
27 public: 27 public:
28 BackgroundFetchServiceImpl( 28 BackgroundFetchServiceImpl(
29 scoped_refptr<BackgroundFetchContext> background_fetch_context, 29 int render_process_id,
30 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 30 scoped_refptr<BackgroundFetchContext> background_fetch_context);
31 ~BackgroundFetchServiceImpl() override; 31 ~BackgroundFetchServiceImpl() override;
32 32
33 static void Create( 33 static void Create(
34 int render_process_id,
34 scoped_refptr<BackgroundFetchContext> background_fetch_context, 35 scoped_refptr<BackgroundFetchContext> background_fetch_context,
35 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
36 blink::mojom::BackgroundFetchServiceRequest request); 36 blink::mojom::BackgroundFetchServiceRequest request);
37 37
38 // blink::mojom::BackgroundFetchService implementation. 38 // blink::mojom::BackgroundFetchService implementation.
39 void Fetch(int64_t service_worker_registration_id, 39 void Fetch(int64_t service_worker_registration_id,
40 const url::Origin& origin, 40 const url::Origin& origin,
41 const std::string& tag, 41 const std::string& tag,
42 const BackgroundFetchOptions& options, 42 const BackgroundFetchOptions& options,
43 const FetchCallback& callback) override; 43 const FetchCallback& callback) override;
44 void UpdateUI(int64_t service_worker_registration_id, 44 void UpdateUI(int64_t service_worker_registration_id,
45 const url::Origin& origin, 45 const url::Origin& origin,
46 const std::string& tag, 46 const std::string& tag,
47 const std::string& title, 47 const std::string& title,
48 const UpdateUICallback& callback) override; 48 const UpdateUICallback& callback) override;
49 void Abort(int64_t service_worker_registration_id, 49 void Abort(int64_t service_worker_registration_id,
50 const url::Origin& origin, 50 const url::Origin& origin,
51 const std::string& tag, 51 const std::string& tag,
52 const AbortCallback& callback) override; 52 const AbortCallback& callback) override;
53 void GetRegistration(int64_t service_worker_registration_id, 53 void GetRegistration(int64_t service_worker_registration_id,
54 const url::Origin& origin, 54 const url::Origin& origin,
55 const std::string& tag, 55 const std::string& tag,
56 const GetRegistrationCallback& callback) override; 56 const GetRegistrationCallback& callback) override;
57 void GetTags(int64_t service_worker_registration_id, 57 void GetTags(int64_t service_worker_registration_id,
58 const url::Origin& origin, 58 const url::Origin& origin,
59 const GetTagsCallback& callback) override; 59 const GetTagsCallback& callback) override;
60 60
61 private: 61 private:
62 // Validates and returns whether the |tag| contains a valid value. The
63 // renderer will be flagged for having send a bad message if it isn't.
64 bool ValidateTag(const std::string& tag) WARN_UNUSED_RESULT;
65
66 // Validates and returns whether |requests| contains at least a valid request.
67 // The renderer will be flagged for having send a bad message if it isn't.
68 bool ValidateRequests(const std::vector<ServiceWorkerFetchRequest>& requests)
69 WARN_UNUSED_RESULT;
70
71 // Validates and returns whether the |title| contains a valid value. The
72 // renderer will be flagged for having send a bad message if it isn't.
73 bool ValidateTitle(const std::string& title) WARN_UNUSED_RESULT;
74
75 // Id of the renderer process that this service has been created for.
76 int render_process_id_;
77
78 // The Background Fetch context on which operations will be dispatched.
62 scoped_refptr<BackgroundFetchContext> background_fetch_context_; 79 scoped_refptr<BackgroundFetchContext> background_fetch_context_;
63 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
64 80
65 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchServiceImpl); 81 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchServiceImpl);
66 }; 82 };
67 83
68 } // namespace content 84 } // namespace content
69 85
70 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_SERVICE_IMPL_H_ 86 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698