Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: content/public/browser/service_worker_context.h

Issue 1429753002: ServiceWorker: Remove dead code from ServiceWorkerContextWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix "include" dependency Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "content/public/browser/service_worker_usage_info.h" 13 #include "content/public/browser/service_worker_usage_info.h"
14 #include "net/base/completion_callback.h"
15 #include "url/gurl.h" 14 #include "url/gurl.h"
16 15
17 namespace net {
18 class URLRequest;
19 }
20
21 namespace content { 16 namespace content {
22 17
23 // Represents the per-StoragePartition ServiceWorker data. 18 // Represents the per-StoragePartition ServiceWorker data.
24 class ServiceWorkerContext { 19 class ServiceWorkerContext {
25 public: 20 public:
26 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: 21 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope:
27 // roughly, must be of the form "<origin>/<path>/*". 22 // roughly, must be of the form "<origin>/<path>/*".
28 typedef GURL Scope; 23 typedef GURL Scope;
29 24
30 typedef base::Callback<void(bool success)> ResultCallback; 25 typedef base::Callback<void(bool success)> ResultCallback;
31 26
32 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& 27 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>&
33 usage_info)> GetUsageInfoCallback; 28 usage_info)> GetUsageInfoCallback;
34 29
35 typedef base::Callback<void(bool has_service_worker)> 30 typedef base::Callback<void(bool has_service_worker)>
36 CheckHasServiceWorkerCallback; 31 CheckHasServiceWorkerCallback;
37 32
38 // Registers the header name which should not be passed to the ServiceWorker. 33 // Registers the header name which should not be passed to the ServiceWorker.
39 // Must be called from the IO thread. 34 // Must be called from the IO thread.
40 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( 35 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent(
41 const std::set<std::string>& header_names); 36 const std::set<std::string>& header_names);
42 37
43 // Returns true if the header name should not be passed to the ServiceWorker. 38 // Returns true if the header name should not be passed to the ServiceWorker.
44 // Must be called from the IO thread. 39 // Must be called from the IO thread.
45 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); 40 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name);
46 41
47 // Retrieves the ServiceWorkerContext, if any, associated with |request|.
48 CONTENT_EXPORT static ServiceWorkerContext* GetServiceWorkerContext(
49 net::URLRequest* request);
50
51 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: 42 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope:
52 // pattern}) from a renderer, except that |pattern| is an absolute URL instead 43 // pattern}) from a renderer, except that |pattern| is an absolute URL instead
53 // of relative to some current origin. |callback| is passed true when the JS 44 // of relative to some current origin. |callback| is passed true when the JS
54 // promise is fulfilled or false when the JS promise is rejected. 45 // promise is fulfilled or false when the JS promise is rejected.
55 // 46 //
56 // The registration can fail if: 47 // The registration can fail if:
57 // * |script_url| is on a different origin from |pattern| 48 // * |script_url| is on a different origin from |pattern|
58 // * Fetching |script_url| fails. 49 // * Fetching |script_url| fails.
59 // * |script_url| fails to parse or its top-level execution fails. 50 // * |script_url| fails to parse or its top-level execution fails.
60 // TODO: The error message for this needs to be available to developers. 51 // TODO: The error message for this needs to be available to developers.
61 // * Something unexpected goes wrong, like a renderer crash or a full disk. 52 // * Something unexpected goes wrong, like a renderer crash or a full disk.
62 virtual void RegisterServiceWorker(const Scope& pattern, 53 virtual void RegisterServiceWorker(const Scope& pattern,
63 const GURL& script_url, 54 const GURL& script_url,
64 const ResultCallback& callback) = 0; 55 const ResultCallback& callback) = 0;
65 56
66 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a 57 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a
67 // renderer, except that |pattern| is an absolute URL instead of relative to 58 // renderer, except that |pattern| is an absolute URL instead of relative to
68 // some current origin. |callback| is passed true when the JS promise is 59 // some current origin. |callback| is passed true when the JS promise is
69 // fulfilled or false when the JS promise is rejected. 60 // fulfilled or false when the JS promise is rejected.
70 // 61 //
71 // Unregistration can fail if: 62 // Unregistration can fail if:
72 // * No Service Worker was registered for |pattern|. 63 // * No Service Worker was registered for |pattern|.
73 // * Something unexpected goes wrong, like a renderer crash. 64 // * Something unexpected goes wrong, like a renderer crash.
74 virtual void UnregisterServiceWorker(const Scope& pattern, 65 virtual void UnregisterServiceWorker(const Scope& pattern,
75 const ResultCallback& callback) = 0; 66 const ResultCallback& callback) = 0;
76 67
77 // TODO(jyasskin): Provide a way to SendMessage to a Scope.
78
79 // Determines if a request for |url| can be satisfied while offline.
80 // This method always completes asynchronously.
81 virtual void CanHandleMainResourceOffline(const GURL& url,
82 const GURL& first_party,
83 const net::CompletionCallback&
84 callback) = 0;
85
86 // Methods used in response to browsing data and quota manager requests. 68 // Methods used in response to browsing data and quota manager requests.
87 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; 69 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0;
88 virtual void DeleteForOrigin(const GURL& origin_url, 70 virtual void DeleteForOrigin(const GURL& origin_url,
89 const ResultCallback& callback) = 0; 71 const ResultCallback& callback) = 0;
90 72
91 // Returns true if an active Service Worker registration exists that matches 73 // Returns true if an active Service Worker registration exists that matches
92 // |url|, and if |other_url| falls inside the scope of the same registration. 74 // |url|, and if |other_url| falls inside the scope of the same registration.
93 // Note this still returns true even if there is a Service Worker registration 75 // Note this still returns true even if there is a Service Worker registration
94 // which has a longer match for |other_url|. 76 // which has a longer match for |other_url|.
95 // This function can be called from any thread, but the callback will always 77 // This function can be called from any thread, but the callback will always
(...skipping 12 matching lines...) Expand all
108 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; 90 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0;
109 91
110 protected: 92 protected:
111 ServiceWorkerContext() {} 93 ServiceWorkerContext() {}
112 virtual ~ServiceWorkerContext() {} 94 virtual ~ServiceWorkerContext() {}
113 }; 95 };
114 96
115 } // namespace content 97 } // namespace content
116 98
117 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 99 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_request_handler.h ('k') | extensions/browser/service_worker_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698