| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/common/service_worker/service_worker_types.h" |
| 14 #include "webkit/common/resource_type.h" | 15 #include "webkit/common/resource_type.h" |
| 15 | 16 |
| 16 namespace IPC { | 17 namespace IPC { |
| 17 class Sender; | 18 class Sender; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace webkit_blob { | 21 namespace webkit_blob { |
| 21 class BlobStorageContext; | 22 class BlobStorageContext; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 class ServiceWorkerContextCore; | 27 class ServiceWorkerContextCore; |
| 27 class ServiceWorkerDispatcherHost; | 28 class ServiceWorkerDispatcherHost; |
| 28 class ServiceWorkerRequestHandler; | 29 class ServiceWorkerRequestHandler; |
| 29 class ServiceWorkerVersion; | 30 class ServiceWorkerVersion; |
| 30 | 31 |
| 31 // This class is the browser-process representation of a serice worker | 32 // This class is the browser-process representation of a service worker |
| 32 // provider. There is a provider per document and the lifetime of this | 33 // provider. There is a provider per document and the lifetime of this |
| 33 // object is tied to the lifetime of its document in the renderer process. | 34 // object is tied to the lifetime of its document in the renderer process. |
| 34 // This class holds service worker state that is scoped to an individual | 35 // This class holds service worker state that is scoped to an individual |
| 35 // document. | 36 // document. |
| 36 // | 37 // |
| 37 // Note this class can also host a running service worker, in which | 38 // Note this class can also host a running service worker, in which |
| 38 // case it will observe resource loads made directly by the service worker. | 39 // case it will observe resource loads made directly by the service worker. |
| 39 class CONTENT_EXPORT ServiceWorkerProviderHost | 40 class CONTENT_EXPORT ServiceWorkerProviderHost |
| 40 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 41 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
| 41 public: | 42 public: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // the request doesn't require special handling. | 88 // the request doesn't require special handling. |
| 88 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( | 89 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( |
| 89 ResourceType::Type resource_type, | 90 ResourceType::Type resource_type, |
| 90 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context); | 91 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context); |
| 91 | 92 |
| 92 // Dispatches message event to the document. | 93 // Dispatches message event to the document. |
| 93 void PostMessage(const base::string16& message, | 94 void PostMessage(const base::string16& message, |
| 94 const std::vector<int>& sent_message_port_ids); | 95 const std::vector<int>& sent_message_port_ids); |
| 95 | 96 |
| 96 private: | 97 private: |
| 98 // Creates a ServiceWorkerHandle to retain |version| and returns a |
| 99 // ServiceWorkerInfo with the handle ID to pass to the provider. The |
| 100 // provider is responsible for releasing the handle. |
| 101 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); |
| 102 |
| 97 const int process_id_; | 103 const int process_id_; |
| 98 const int provider_id_; | 104 const int provider_id_; |
| 99 GURL document_url_; | 105 GURL document_url_; |
| 100 scoped_refptr<ServiceWorkerVersion> active_version_; | 106 scoped_refptr<ServiceWorkerVersion> active_version_; |
| 101 scoped_refptr<ServiceWorkerVersion> waiting_version_; | 107 scoped_refptr<ServiceWorkerVersion> waiting_version_; |
| 102 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 108 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
| 103 base::WeakPtr<ServiceWorkerContextCore> context_; | 109 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 104 ServiceWorkerDispatcherHost* dispatcher_host_; | 110 ServiceWorkerDispatcherHost* dispatcher_host_; |
| 105 | 111 |
| 106 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 112 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 107 }; | 113 }; |
| 108 | 114 |
| 109 } // namespace content | 115 } // namespace content |
| 110 | 116 |
| 111 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 117 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |