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 "base/callback_list.h" |
10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 // Represents the per-StoragePartition ServiceWorker data. Must be used from | 15 // Represents the per-StoragePartition ServiceWorker data. Must be used from |
15 // the UI thread. | 16 // the UI thread. |
16 class ServiceWorkerContext { | 17 class ServiceWorkerContext { |
17 public: | 18 public: |
18 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/
index.html#url-scope: | 19 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/
index.html#url-scope: |
19 // roughly, must be of the form "<origin>/<path>/*". | 20 // roughly, must be of the form "<origin>/<path>/*". |
(...skipping 25 matching lines...) Expand all Loading... |
45 // | 46 // |
46 // Unregistration can fail if: | 47 // Unregistration can fail if: |
47 // * No Service Worker was registered for |pattern|. | 48 // * No Service Worker was registered for |pattern|. |
48 // * Something unexpected goes wrong, like a renderer crash. | 49 // * Something unexpected goes wrong, like a renderer crash. |
49 virtual void UnregisterServiceWorker(const Scope& pattern, | 50 virtual void UnregisterServiceWorker(const Scope& pattern, |
50 int source_process_id, | 51 int source_process_id, |
51 const ResultCallback& callback) = 0; | 52 const ResultCallback& callback) = 0; |
52 | 53 |
53 // TODO(jyasskin): Provide a way to SendMessage to a Scope. | 54 // TODO(jyasskin): Provide a way to SendMessage to a Scope. |
54 | 55 |
| 56 virtual scoped_ptr<base::CallbackList<void(void)>::Subscription> |
| 57 RegisterStatusChangeCallback( |
| 58 const base::Callback<void(void)>& callback) = 0; |
| 59 |
| 60 class ServiceWorkerInfo { |
| 61 public: |
| 62 ServiceWorkerInfo(int worker_process_id, |
| 63 int embedded_worker_id, |
| 64 const GURL& scope, |
| 65 const GURL& url, |
| 66 int worker_devtools_agent_route_id) |
| 67 : worker_process_id(worker_process_id), |
| 68 embedded_worker_id(embedded_worker_id), |
| 69 scope(scope), |
| 70 url(url), |
| 71 worker_devtools_agent_route_id(worker_devtools_agent_route_id) {} |
| 72 int worker_process_id; |
| 73 int embedded_worker_id; |
| 74 GURL scope; |
| 75 GURL url; |
| 76 int worker_devtools_agent_route_id; |
| 77 }; |
| 78 typedef base::Callback<void(const std::vector< |
| 79 ServiceWorkerInfo>& registrations)> GetRunningServiceWorkerInfoCallback; |
| 80 virtual void GetRunningServiceWorkerInfo( |
| 81 const GetRunningServiceWorkerInfoCallback& callback) = 0; |
| 82 |
55 protected: | 83 protected: |
56 ServiceWorkerContext() {} | 84 ServiceWorkerContext() {} |
57 virtual ~ServiceWorkerContext() {} | 85 virtual ~ServiceWorkerContext() {} |
58 }; | 86 }; |
59 | 87 |
60 } // namespace content | 88 } // namespace content |
61 | 89 |
62 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 90 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
OLD | NEW |