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

Side by Side Diff: content/browser/service_worker/embedded_worker_test_helper.h

Issue 1187623006: Service Worker: Update stale workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix DCHECK Created 5 years, 6 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
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
7 7
8 #include <map>
9 #include <string>
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "ipc/ipc_listener.h" 14 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_test_sink.h" 15 #include "ipc/ipc_test_sink.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h" 17 #include "url/gurl.h"
16 18
17 struct EmbeddedWorkerMsg_StartWorker_Params; 19 struct EmbeddedWorkerMsg_StartWorker_Params;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 94
93 // On*Event handlers. Called by the default implementation of 95 // On*Event handlers. Called by the default implementation of
94 // OnMessageToWorker when events are sent to the embedded 96 // OnMessageToWorker when events are sent to the embedded
95 // worker. By default they just return success via 97 // worker. By default they just return success via
96 // SimulateSendReplyToBrowser. 98 // SimulateSendReplyToBrowser.
97 virtual void OnActivateEvent(int embedded_worker_id, int request_id); 99 virtual void OnActivateEvent(int embedded_worker_id, int request_id);
98 virtual void OnInstallEvent(int embedded_worker_id, int request_id); 100 virtual void OnInstallEvent(int embedded_worker_id, int request_id);
99 virtual void OnFetchEvent(int embedded_worker_id, 101 virtual void OnFetchEvent(int embedded_worker_id,
100 int request_id, 102 int request_id,
101 const ServiceWorkerFetchRequest& request); 103 const ServiceWorkerFetchRequest& request);
104 virtual void OnPushEvent(int embedded_worker_id,
105 int request_id,
106 const std::string& data);
102 107
103 // These functions simulate sending an EmbeddedHostMsg message to the 108 // These functions simulate sending an EmbeddedHostMsg message to the
104 // browser. 109 // browser.
105 void SimulatePausedAfterDownload(int embedded_worker_id); 110 void SimulatePausedAfterDownload(int embedded_worker_id);
106 void SimulateWorkerReadyForInspection(int embedded_worker_id); 111 void SimulateWorkerReadyForInspection(int embedded_worker_id);
107 void SimulateWorkerScriptCached(int embedded_worker_id); 112 void SimulateWorkerScriptCached(int embedded_worker_id);
108 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id); 113 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id);
109 void SimulateWorkerScriptEvaluated(int embedded_worker_id); 114 void SimulateWorkerScriptEvaluated(int embedded_worker_id);
110 void SimulateWorkerStarted(int embedded_worker_id); 115 void SimulateWorkerStarted(int embedded_worker_id);
111 void SimulateWorkerStopped(int embedded_worker_id); 116 void SimulateWorkerStopped(int embedded_worker_id);
112 void SimulateSend(IPC::Message* message); 117 void SimulateSend(IPC::Message* message);
113 118
114 EmbeddedWorkerRegistry* registry(); 119 EmbeddedWorkerRegistry* registry();
115 120
116 private: 121 private:
117 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); 122 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params);
118 void OnResumeAfterDownloadStub(int embedded_worker_id); 123 void OnResumeAfterDownloadStub(int embedded_worker_id);
119 void OnStopWorkerStub(int embedded_worker_id); 124 void OnStopWorkerStub(int embedded_worker_id);
120 void OnMessageToWorkerStub(int thread_id, 125 void OnMessageToWorkerStub(int thread_id,
121 int embedded_worker_id, 126 int embedded_worker_id,
122 const IPC::Message& message); 127 const IPC::Message& message);
123 void OnActivateEventStub(int request_id); 128 void OnActivateEventStub(int request_id);
124 void OnInstallEventStub(int request_id); 129 void OnInstallEventStub(int request_id);
125 void OnFetchEventStub(int request_id, 130 void OnFetchEventStub(int request_id,
126 const ServiceWorkerFetchRequest& request); 131 const ServiceWorkerFetchRequest& request);
132 void OnPushEventStub(int request_id, const std::string& data);
127 133
128 MessagePortMessageFilter* NewMessagePortMessageFilter(); 134 MessagePortMessageFilter* NewMessagePortMessageFilter();
129 135
130 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; 136 scoped_refptr<ServiceWorkerContextWrapper> wrapper_;
131 137
132 IPC::TestSink sink_; 138 IPC::TestSink sink_;
133 IPC::TestSink inner_sink_; 139 IPC::TestSink inner_sink_;
134 140
135 int next_thread_id_; 141 int next_thread_id_;
136 int mock_render_process_id_; 142 int mock_render_process_id_;
137 143
138 std::map<int, int64> embedded_worker_id_service_worker_version_id_map_; 144 std::map<int, int64> embedded_worker_id_service_worker_version_id_map_;
139 145
140 // Updated each time MessageToWorker message is received. 146 // Updated each time MessageToWorker message is received.
141 int current_embedded_worker_id_; 147 int current_embedded_worker_id_;
142 148
143 std::vector<scoped_refptr<MessagePortMessageFilter>> 149 std::vector<scoped_refptr<MessagePortMessageFilter>>
144 message_port_message_filters_; 150 message_port_message_filters_;
145 151
146 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; 152 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_;
147 153
148 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); 154 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper);
149 }; 155 };
150 156
151 } // namespace content 157 } // namespace content
152 158
153 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698