| OLD | NEW |
| 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_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "content/public/browser/service_worker_usage_info.h" | 10 #include "content/public/browser/service_worker_usage_info.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Represents the per-StoragePartition ServiceWorker data. Must be used from | 15 // Represents the per-StoragePartition ServiceWorker data. |
| 16 // the IO thread. | |
| 17 class ServiceWorkerContext { | 16 class ServiceWorkerContext { |
| 18 public: | 17 public: |
| 19 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/
index.html#url-scope: | 18 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/
index.html#url-scope: |
| 20 // roughly, must be of the form "<origin>/<path>/*". | 19 // roughly, must be of the form "<origin>/<path>/*". |
| 21 typedef GURL Scope; | 20 typedef GURL Scope; |
| 22 | 21 |
| 23 typedef base::Callback<void(bool success)> ResultCallback; | 22 typedef base::Callback<void(bool success)> ResultCallback; |
| 24 | 23 |
| 25 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& | 24 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& |
| 26 usage_info)> GetUsageInfoCallback; | 25 usage_info)> GetUsageInfoCallback; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 // fulfilled or false when the JS promise is rejected. | 45 // fulfilled or false when the JS promise is rejected. |
| 47 // | 46 // |
| 48 // Unregistration can fail if: | 47 // Unregistration can fail if: |
| 49 // * No Service Worker was registered for |pattern|. | 48 // * No Service Worker was registered for |pattern|. |
| 50 // * Something unexpected goes wrong, like a renderer crash. | 49 // * Something unexpected goes wrong, like a renderer crash. |
| 51 virtual void UnregisterServiceWorker(const Scope& pattern, | 50 virtual void UnregisterServiceWorker(const Scope& pattern, |
| 52 const ResultCallback& callback) = 0; | 51 const ResultCallback& callback) = 0; |
| 53 | 52 |
| 54 // TODO(jyasskin): Provide a way to SendMessage to a Scope. | 53 // TODO(jyasskin): Provide a way to SendMessage to a Scope. |
| 55 | 54 |
| 56 // Synchronously releases all of the RenderProcessHosts that have Service | |
| 57 // Workers running inside them, and prevents any new Service Worker instances | |
| 58 // from starting up. | |
| 59 virtual void Terminate() = 0; | |
| 60 | |
| 61 // Methods used in response to browsing data and quota manager requests. | 55 // Methods used in response to browsing data and quota manager requests. |
| 62 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; | 56 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; |
| 63 virtual void DeleteForOrigin(const GURL& origin_url) = 0; | 57 virtual void DeleteForOrigin(const GURL& origin_url) = 0; |
| 64 | 58 |
| 65 protected: | 59 protected: |
| 66 ServiceWorkerContext() {} | 60 ServiceWorkerContext() {} |
| 67 virtual ~ServiceWorkerContext() {} | 61 virtual ~ServiceWorkerContext() {} |
| 68 }; | 62 }; |
| 69 | 63 |
| 70 } // namespace content | 64 } // namespace content |
| 71 | 65 |
| 72 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 66 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| OLD | NEW |