Make sure webrtc::VideoSourceInterface is released on the main render thread.
[chromium-blink-merge.git] / content / public / browser / service_worker_context.h
bloba701d6c7a56176168fc9593f05c025d2cea70db7
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.
5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "url/gurl.h"
12 namespace content {
14 // Represents the per-StoragePartition ServiceWorker data. Must be used from
15 // the UI thread.
16 class ServiceWorkerContext {
17 public:
18 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/index.html#url-scope:
19 // roughly, must be of the form "<origin>/<path>/*".
20 typedef GURL Scope;
22 typedef base::Callback<void(bool success)> ResultCallback;
24 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope:
25 // pattern}) from a renderer, except that |pattern| is an absolute URL instead
26 // of relative to some current origin. |callback| is passed true when the JS
27 // promise is fulfilled or false when the JS promise is rejected.
29 // The registration can fail if:
30 // * |script_url| is on a different origin from |pattern|
31 // * Fetching |script_url| fails.
32 // * |script_url| fails to parse or its top-level execution fails.
33 // TODO: The error message for this needs to be available to developers.
34 // * Something unexpected goes wrong, like a renderer crash or a full disk.
35 virtual void RegisterServiceWorker(const Scope& pattern,
36 const GURL& script_url,
37 const ResultCallback& callback) = 0;
39 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a
40 // renderer, except that |pattern| is an absolute URL instead of relative to
41 // some current origin. |callback| is passed true when the JS promise is
42 // fulfilled or false when the JS promise is rejected.
44 // Unregistration can fail if:
45 // * No Service Worker was registered for |pattern|.
46 // * Something unexpected goes wrong, like a renderer crash.
47 virtual void UnregisterServiceWorker(const Scope& pattern,
48 const ResultCallback& callback) = 0;
50 // TODO(jyasskin): Provide a way to SendMessage to a Scope.
52 protected:
53 ServiceWorkerContext() {}
54 virtual ~ServiceWorkerContext() {}
57 } // namespace content
59 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_