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

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

Issue 261533003: Populate .current when navigator.serviceWorker is accessed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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_IMPL_H_ 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_IMPL_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_IMPL_H_ 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_IMPL_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/supports_user_data.h" 11 #include "base/supports_user_data.h"
11 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
12 13
13 namespace content { 14 namespace content {
14 15
16 class ServiceWorkerProviderContext;
17
15 // A unique provider_id is generated for each instance. 18 // A unique provider_id is generated for each instance.
16 // Instantiated prior to the main resource load being started and remains 19 // Instantiated prior to the main resource load being started and remains
17 // allocated until after the last subresource load has occurred. 20 // allocated until after the last subresource load has occurred.
18 // This is used to track the lifetime of a Document to create 21 // This is used to track the lifetime of a Document to create
19 // and dispose the ServiceWorkerProviderHost in the browser process 22 // and dispose the ServiceWorkerProviderHost in the browser process
20 // to match its lifetime. Each request coming from the Document is 23 // to match its lifetime. Each request coming from the Document is
21 // tagged with this id in willSendRequest. 24 // tagged with this id in willSendRequest.
22 // 25 //
23 // Basically, it's a scoped integer that sends an ipc upon construction 26 // Basically, it's a scoped integer that sends an ipc upon construction
24 // and destruction. 27 // and destruction.
25 class CONTENT_EXPORT ServiceWorkerNetworkProvider 28 class CONTENT_EXPORT ServiceWorkerNetworkProvider
26 : public base::SupportsUserData::Data { 29 : public base::SupportsUserData::Data {
27 public: 30 public:
28 // Ownership is transferred to the DocumentState. 31 // Ownership is transferred to the DocumentState.
29 static void AttachToDocumentState( 32 static void AttachToDocumentState(
30 base::SupportsUserData* document_state, 33 base::SupportsUserData* document_state,
31 scoped_ptr<ServiceWorkerNetworkProvider> network_provider); 34 scoped_ptr<ServiceWorkerNetworkProvider> network_provider);
32 35
33 static ServiceWorkerNetworkProvider* FromDocumentState( 36 static ServiceWorkerNetworkProvider* FromDocumentState(
34 base::SupportsUserData* document_state); 37 base::SupportsUserData* document_state);
35 38
36 ServiceWorkerNetworkProvider(); 39 ServiceWorkerNetworkProvider();
37 virtual ~ServiceWorkerNetworkProvider(); 40 virtual ~ServiceWorkerNetworkProvider();
38 41
39 int provider_id() const { return provider_id_; } 42 int provider_id() const { return provider_id_; }
43 ServiceWorkerProviderContext* context() { return context_.get(); }
40 44
41 // This method is called for a provider that's associated with a 45 // This method is called for a provider that's associated with a
42 // running service worker script. The version_id indicates which 46 // running service worker script. The version_id indicates which
43 // ServiceWorkerVersion should be used. 47 // ServiceWorkerVersion should be used.
44 void SetServiceWorkerVersionId(int64 version_id); 48 void SetServiceWorkerVersionId(int64 version_id);
45 49
46 private: 50 private:
47 const int provider_id_; 51 const int provider_id_;
52 scoped_refptr<ServiceWorkerProviderContext> context_;
48 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider); 53 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider);
49 }; 54 };
50 55
51 } // namespace content 56 } // namespace content
52 57
53 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_ 58 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698