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

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.h

Issue 379303002: Content blink::WebServiceWorkerCacheStorage implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review for style Created 6 years, 4 months 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 | Annotate | Revision Log
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_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/id_map.h" 12 #include "base/id_map.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "content/child/webmessageportchannel_impl.h" 15 #include "content/child/webmessageportchannel_impl.h"
15 #include "content/common/service_worker/service_worker_types.h" 16 #include "content/common/service_worker/service_worker_types.h"
17 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche r.h"
16 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" 18 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
17 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" 19 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h"
18 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" 20 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
19 21
20 namespace blink { 22 namespace blink {
21 class WebServiceWorkerContextProxy; 23 class WebServiceWorkerContextProxy;
22 } 24 }
23 25
24 namespace IPC { 26 namespace IPC {
25 class Message; 27 class Message;
26 } 28 }
27 29
28 namespace content { 30 namespace content {
29 31
30 class EmbeddedWorkerContextClient; 32 class EmbeddedWorkerContextClient;
33 class ServiceWorkerCacheStorageDispatcher;
31 34
32 // TODO(kinuko): This should implement WebServiceWorkerContextClient 35 // TODO(kinuko): This should implement WebServiceWorkerContextClient
33 // rather than having EmbeddedWorkerContextClient implement it. 36 // rather than having EmbeddedWorkerContextClient implement it.
34 // See the header comment in embedded_worker_context_client.h for the 37 // See the header comment in embedded_worker_context_client.h for the
35 // potential EW/SW layering concerns. 38 // potential EW/SW layering concerns.
36 class ServiceWorkerScriptContext { 39 class ServiceWorkerScriptContext {
37 public: 40 public:
38 ServiceWorkerScriptContext( 41 ServiceWorkerScriptContext(
39 EmbeddedWorkerContextClient* embedded_context, 42 EmbeddedWorkerContextClient* embedded_context,
40 blink::WebServiceWorkerContextProxy* proxy); 43 blink::WebServiceWorkerContextProxy* proxy);
41 ~ServiceWorkerScriptContext(); 44 ~ServiceWorkerScriptContext();
42 45
43 void OnMessageReceived(const IPC::Message& message); 46 void OnMessageReceived(const IPC::Message& message);
44 47
45 void DidHandleActivateEvent(int request_id, 48 void DidHandleActivateEvent(int request_id,
46 blink::WebServiceWorkerEventResult); 49 blink::WebServiceWorkerEventResult);
47 void DidHandleInstallEvent(int request_id, 50 void DidHandleInstallEvent(int request_id,
48 blink::WebServiceWorkerEventResult result); 51 blink::WebServiceWorkerEventResult result);
49 void DidHandleFetchEvent(int request_id, 52 void DidHandleFetchEvent(int request_id,
50 ServiceWorkerFetchEventResult result, 53 ServiceWorkerFetchEventResult result,
51 const ServiceWorkerResponse& response); 54 const ServiceWorkerResponse& response);
52 void DidHandleSyncEvent(int request_id); 55 void DidHandleSyncEvent(int request_id);
53 void GetClientDocuments( 56 void GetClientDocuments(
54 blink::WebServiceWorkerClientsCallbacks* callbacks); 57 blink::WebServiceWorkerClientsCallbacks* callbacks);
55 void PostMessageToDocument( 58 void PostMessageToDocument(
56 int client_id, 59 int client_id,
57 const base::string16& message, 60 const base::string16& message,
58 scoped_ptr<blink::WebMessagePortChannelArray> channels); 61 scoped_ptr<blink::WebMessagePortChannelArray> channels);
59 62
63 // Send a message to the browser. Takes ownership of message.
64 void Send(IPC::Message* message);
65
66 // Get routing_id for sending message to the ServiceWorkerVersion
67 // in the browser process.
68 int GetRoutingID() const;
69
70 blink::WebServiceWorkerCacheStorage* cache_storage() {
71 return cache_storage_dispatcher_.get();
72 }
73
60 private: 74 private:
61 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> 75 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer>
62 ClientsCallbacksMap; 76 ClientsCallbacksMap;
63 77
64 // Send a message to the browser.
65 void Send(IPC::Message* message);
66 78
67 void OnActivateEvent(int request_id); 79 void OnActivateEvent(int request_id);
68 void OnInstallEvent(int request_id, int active_version_id); 80 void OnInstallEvent(int request_id, int active_version_id);
69 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); 81 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request);
70 void OnSyncEvent(int request_id); 82 void OnSyncEvent(int request_id);
71 void OnPushEvent(int request_id, const std::string& data); 83 void OnPushEvent(int request_id, const std::string& data);
72 void OnPostMessage(const base::string16& message, 84 void OnPostMessage(const base::string16& message,
73 const std::vector<int>& sent_message_port_ids, 85 const std::vector<int>& sent_message_port_ids,
74 const std::vector<int>& new_routing_ids); 86 const std::vector<int>& new_routing_ids);
75 void OnDidGetClientDocuments( 87 void OnDidGetClientDocuments(
76 int request_id, const std::vector<int>& client_ids); 88 int request_id, const std::vector<int>& client_ids);
77 89
78 // Get routing_id for sending message to the ServiceWorkerVersion 90
falken 2014/07/28 04:48:59 nit: extra newline
gavinp 2014/07/28 04:55:27 Done.
79 // in the browser process. 91 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_;
80 int GetRoutingID() const;
81 92
82 // Not owned; embedded_context_ owns this. 93 // Not owned; embedded_context_ owns this.
83 EmbeddedWorkerContextClient* embedded_context_; 94 EmbeddedWorkerContextClient* embedded_context_;
84 95
85 // Not owned; this object is destroyed when proxy_ becomes invalid. 96 // Not owned; this object is destroyed when proxy_ becomes invalid.
86 blink::WebServiceWorkerContextProxy* proxy_; 97 blink::WebServiceWorkerContextProxy* proxy_;
87 98
88 // Used for incoming messages from the browser for which an outgoing response 99 // Used for incoming messages from the browser for which an outgoing response
89 // back to the browser is expected, the id must be sent back with the 100 // back to the browser is expected, the id must be sent back with the
90 // response. 101 // response.
91 int current_request_id_; 102 int current_request_id_;
92 103
93 // Pending callbacks for GetClientDocuments(). 104 // Pending callbacks for GetClientDocuments().
94 ClientsCallbacksMap pending_clients_callbacks_; 105 ClientsCallbacksMap pending_clients_callbacks_;
95 106
96 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); 107 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext);
97 }; 108 };
98 109
99 } // namespace content 110 } // namespace content
100 111
101 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ 112 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698