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

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

Issue 1342733002: ServiceWorker: log when the script's loaded separately from thread start (chromium) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 5 years, 3 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
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 #include "content/browser/service_worker/embedded_worker_test_helper.h" 5 #include "content/browser/service_worker/embedded_worker_test_helper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 void EmbeddedWorkerTestHelper::OnStartWorker(int embedded_worker_id, 109 void EmbeddedWorkerTestHelper::OnStartWorker(int embedded_worker_id,
110 int64 service_worker_version_id, 110 int64 service_worker_version_id,
111 const GURL& scope, 111 const GURL& scope,
112 const GURL& script_url) { 112 const GURL& script_url) {
113 embedded_worker_id_service_worker_version_id_map_[embedded_worker_id] = 113 embedded_worker_id_service_worker_version_id_map_[embedded_worker_id] =
114 service_worker_version_id; 114 service_worker_version_id;
115 SimulateWorkerReadyForInspection(embedded_worker_id); 115 SimulateWorkerReadyForInspection(embedded_worker_id);
116 SimulateWorkerScriptCached(embedded_worker_id); 116 SimulateWorkerScriptCached(embedded_worker_id);
117 SimulateWorkerScriptLoaded(next_thread_id_++, embedded_worker_id); 117 SimulateWorkerScriptLoaded(embedded_worker_id);
118 SimulateWorkerThreadStarted(next_thread_id_++, embedded_worker_id);
118 SimulateWorkerScriptEvaluated(embedded_worker_id); 119 SimulateWorkerScriptEvaluated(embedded_worker_id);
119 SimulateWorkerStarted(embedded_worker_id); 120 SimulateWorkerStarted(embedded_worker_id);
120 } 121 }
121 122
122 void EmbeddedWorkerTestHelper::OnStopWorker(int embedded_worker_id) { 123 void EmbeddedWorkerTestHelper::OnStopWorker(int embedded_worker_id) {
123 // By default just notify the sender that the worker is stopped. 124 // By default just notify the sender that the worker is stopped.
124 SimulateWorkerStopped(embedded_worker_id); 125 SimulateWorkerStopped(embedded_worker_id);
125 } 126 }
126 127
127 bool EmbeddedWorkerTestHelper::OnMessageToWorker( 128 bool EmbeddedWorkerTestHelper::OnMessageToWorker(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 std::vector<ServiceWorkerDatabase::ResourceRecord> records; 201 std::vector<ServiceWorkerDatabase::ResourceRecord> records;
201 // Add a dummy ResourceRecord for the main script to the script cache map of 202 // Add a dummy ResourceRecord for the main script to the script cache map of
202 // the ServiceWorkerVersion. We use embedded_worker_id for resource_id to 203 // the ServiceWorkerVersion. We use embedded_worker_id for resource_id to
203 // avoid ID collision. 204 // avoid ID collision.
204 records.push_back(ServiceWorkerDatabase::ResourceRecord( 205 records.push_back(ServiceWorkerDatabase::ResourceRecord(
205 embedded_worker_id, version->script_url(), 100)); 206 embedded_worker_id, version->script_url(), 100));
206 version->script_cache_map()->SetResources(records); 207 version->script_cache_map()->SetResources(records);
207 } 208 }
208 209
209 void EmbeddedWorkerTestHelper::SimulateWorkerScriptLoaded( 210 void EmbeddedWorkerTestHelper::SimulateWorkerScriptLoaded(
210 int thread_id, int embedded_worker_id) { 211 int embedded_worker_id) {
211 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); 212 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id);
212 ASSERT_TRUE(worker != NULL); 213 ASSERT_TRUE(worker != NULL);
213 registry()->OnWorkerScriptLoaded( 214 registry()->OnWorkerScriptLoaded(worker->process_id(), embedded_worker_id);
214 worker->process_id(), thread_id, embedded_worker_id); 215 }
216
217 void EmbeddedWorkerTestHelper::SimulateWorkerThreadStarted(
218 int thread_id,
219 int embedded_worker_id) {
220 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id);
221 ASSERT_TRUE(worker != NULL);
222 registry()->OnWorkerThreadStarted(worker->process_id(), thread_id,
223 embedded_worker_id);
215 } 224 }
216 225
217 void EmbeddedWorkerTestHelper::SimulateWorkerScriptEvaluated( 226 void EmbeddedWorkerTestHelper::SimulateWorkerScriptEvaluated(
218 int embedded_worker_id) { 227 int embedded_worker_id) {
219 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); 228 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id);
220 ASSERT_TRUE(worker != NULL); 229 ASSERT_TRUE(worker != NULL);
221 registry()->OnWorkerScriptEvaluated( 230 registry()->OnWorkerScriptEvaluated(
222 worker->process_id(), embedded_worker_id, true /* success */); 231 worker->process_id(), embedded_worker_id, true /* success */);
223 } 232 }
224 233
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 339
331 MessagePortMessageFilter* 340 MessagePortMessageFilter*
332 EmbeddedWorkerTestHelper::NewMessagePortMessageFilter() { 341 EmbeddedWorkerTestHelper::NewMessagePortMessageFilter() {
333 scoped_refptr<MessagePortMessageFilter> filter( 342 scoped_refptr<MessagePortMessageFilter> filter(
334 new MockMessagePortMessageFilter); 343 new MockMessagePortMessageFilter);
335 message_port_message_filters_.push_back(filter); 344 message_port_message_filters_.push_back(filter);
336 return filter.get(); 345 return filter.get();
337 } 346 }
338 347
339 } // namespace content 348 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698