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

Side by Side Diff: content/child/service_worker/service_worker_network_provider.h

Issue 2733283004: Expose WebServiceWorkerNetworkProvider on DataSource (Closed)
Patch Set: consistency Created 3 years, 9 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/child/service_worker/service_worker_network_provider.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/supports_user_data.h" 15 #include "base/supports_user_data.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/service_worker/service_worker.mojom.h" 17 #include "content/common/service_worker/service_worker.mojom.h"
18 18
19 namespace blink { 19 namespace blink {
20 class WebLocalFrame; 20 class WebLocalFrame;
21 class WebServiceWorkerNetworkProvider;
21 } // namespace blink 22 } // namespace blink
22 23
23 namespace content { 24 namespace content {
24 25
26 struct RequestNavigationParams;
25 class ServiceWorkerProviderContext; 27 class ServiceWorkerProviderContext;
26 struct RequestNavigationParams;
27 28
28 // A unique provider_id is generated for each instance. 29 // A unique provider_id is generated for each instance.
29 // Instantiated prior to the main resource load being started and remains 30 // Instantiated prior to the main resource load being started and remains
30 // allocated until after the last subresource load has occurred. 31 // allocated until after the last subresource load has occurred.
31 // This is used to track the lifetime of a Document to create 32 // This is used to track the lifetime of a Document to create
32 // and dispose the ServiceWorkerProviderHost in the browser process 33 // and dispose the ServiceWorkerProviderHost in the browser process
33 // to match its lifetime. Each request coming from the Document is 34 // to match its lifetime. Each request coming from the Document is
34 // tagged with this id in willSendRequest. 35 // tagged with this id in willSendRequest.
35 // 36 //
36 // Basically, it's a scoped integer that sends an ipc upon construction 37 // Basically, it's a scoped integer that sends an ipc upon construction
37 // and destruction. 38 // and destruction.
38 class CONTENT_EXPORT ServiceWorkerNetworkProvider 39 class CONTENT_EXPORT ServiceWorkerNetworkProvider {
39 : public base::SupportsUserData::Data {
40 public: 40 public:
41 // Ownership is transferred to the DocumentState. 41 // Creates a ServiceWorkerNetworkProvider for navigation and wraps it
42 static void AttachToDocumentState( 42 // with WebServiceWorkerNetworkProvider to be owned by Blink.
43 base::SupportsUserData* document_state, 43 static std::unique_ptr<blink::WebServiceWorkerNetworkProvider>
44 std::unique_ptr<ServiceWorkerNetworkProvider> network_provider); 44 CreateForNavigation(int route_id,
45 const RequestNavigationParams& request_params,
46 blink::WebLocalFrame* frame,
47 bool content_initiated);
45 48
46 static ServiceWorkerNetworkProvider* FromDocumentState( 49 // Valid only for WebServiceWorkerNetworkProvider created by
47 base::SupportsUserData* document_state); 50 // CreateForNavigation.
48 51 static ServiceWorkerNetworkProvider* FromWebServiceWorkerNetworkProvider(
49 static std::unique_ptr<ServiceWorkerNetworkProvider> CreateForNavigation( 52 blink::WebServiceWorkerNetworkProvider*);
50 int route_id,
51 const RequestNavigationParams& request_params,
52 blink::WebLocalFrame* frame,
53 bool content_initiated);
54 53
55 // PlzNavigate 54 // PlzNavigate
56 // The |browser_provider_id| is initialized by the browser for navigations. 55 // The |browser_provider_id| is initialized by the browser for navigations.
57 ServiceWorkerNetworkProvider(int route_id, 56 ServiceWorkerNetworkProvider(int route_id,
58 ServiceWorkerProviderType type, 57 ServiceWorkerProviderType type,
59 int browser_provider_id, 58 int browser_provider_id,
60 bool is_parent_frame_secure); 59 bool is_parent_frame_secure);
61 ServiceWorkerNetworkProvider(int route_id, 60 ServiceWorkerNetworkProvider(int route_id,
62 ServiceWorkerProviderType type, 61 ServiceWorkerProviderType type,
63 bool is_parent_frame_secure); 62 bool is_parent_frame_secure);
63
64 ServiceWorkerNetworkProvider(); 64 ServiceWorkerNetworkProvider();
65 ~ServiceWorkerNetworkProvider() override; 65 ~ServiceWorkerNetworkProvider();
66 66
67 int provider_id() const { return provider_id_; } 67 int provider_id() const { return provider_id_; }
68 ServiceWorkerProviderContext* context() const { return context_.get(); } 68 ServiceWorkerProviderContext* context() const { return context_.get(); }
69 69
70 // This method is called for a provider that's associated with a 70 // This method is called for a provider that's associated with a
71 // running service worker script. The version_id indicates which 71 // running service worker script. The version_id indicates which
72 // ServiceWorkerVersion should be used. 72 // ServiceWorkerVersion should be used.
73 void SetServiceWorkerVersionId(int64_t version_id, int embedded_worker_id); 73 void SetServiceWorkerVersionId(int64_t version_id, int embedded_worker_id);
74 74
75 bool IsControlledByServiceWorker() const; 75 bool IsControlledByServiceWorker() const;
76 76
77 private: 77 private:
78 const int provider_id_; 78 const int provider_id_;
79 scoped_refptr<ServiceWorkerProviderContext> context_; 79 scoped_refptr<ServiceWorkerProviderContext> context_;
80 mojom::ServiceWorkerDispatcherHostAssociatedPtr dispatcher_host_; 80 mojom::ServiceWorkerDispatcherHostAssociatedPtr dispatcher_host_;
81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider); 81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider);
82 }; 82 };
83 83
84 } // namespace content 84 } // namespace content
85 85
86 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ 86 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/service_worker/service_worker_network_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698