OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_IMPL_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_IMPL_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/supports_user_data.h" |
| 11 #include "content/common/content_export.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // A unique provider_id is generated for each instance. |
| 16 // Instantiated prior to the main resource load being started and remains |
| 17 // allocated until after the last subresource load has occurred. |
| 18 // This is used to track the lifetime of a Document to create |
| 19 // and dispose the ServiceWorkerProviderHost in the browser process |
| 20 // to match its lifetime. Each request coming from the Document is |
| 21 // tagged with this id in willSendRequest. |
| 22 // |
| 23 // Basically, it's a scoped integer that sends an ipc upon construction |
| 24 // and destruction. |
| 25 class CONTENT_EXPORT ServiceWorkerNetworkProvider |
| 26 : public base::SupportsUserData::Data { |
| 27 public: |
| 28 // Ownership is transferred to the DocumentState. |
| 29 static void AttachToDocumentState( |
| 30 base::SupportsUserData* document_state, |
| 31 scoped_ptr<ServiceWorkerNetworkProvider> network_provider); |
| 32 |
| 33 static ServiceWorkerNetworkProvider* FromDocumentState( |
| 34 base::SupportsUserData* document_state); |
| 35 |
| 36 ServiceWorkerNetworkProvider(); |
| 37 virtual ~ServiceWorkerNetworkProvider(); |
| 38 |
| 39 int provider_id() const { return provider_id_; } |
| 40 |
| 41 private: |
| 42 const int provider_id_; |
| 43 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider); |
| 44 }; |
| 45 |
| 46 } // namespace content |
| 47 |
| 48 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_ |
OLD | NEW |