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

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

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_instance.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
6 9
7 #include "base/macros.h" 10 #include "base/macros.h"
8 #include "base/run_loop.h" 11 #include "base/run_loop.h"
9 #include "base/stl_util.h" 12 #include "base/stl_util.h"
10 #include "content/browser/service_worker/embedded_worker_instance.h"
11 #include "content/browser/service_worker/embedded_worker_registry.h" 13 #include "content/browser/service_worker/embedded_worker_registry.h"
12 #include "content/browser/service_worker/embedded_worker_test_helper.h" 14 #include "content/browser/service_worker/embedded_worker_test_helper.h"
13 #include "content/browser/service_worker/service_worker_context_core.h" 15 #include "content/browser/service_worker/service_worker_context_core.h"
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" 16 #include "content/browser/service_worker/service_worker_context_wrapper.h"
15 #include "content/common/service_worker/embedded_worker_messages.h" 17 #include "content/common/service_worker/embedded_worker_messages.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 namespace content { 22 namespace content {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 worker->AddListener(this); 260 worker->AddListener(this);
259 261
260 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( 262 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params(
261 new EmbeddedWorkerMsg_StartWorker_Params()); 263 new EmbeddedWorkerMsg_StartWorker_Params());
262 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 264 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
263 265
264 // Pretend the worker got stopped before the start sequence reached 266 // Pretend the worker got stopped before the start sequence reached
265 // SendStartWorker. 267 // SendStartWorker.
266 worker->status_ = EmbeddedWorkerInstance::STOPPED; 268 worker->status_ = EmbeddedWorkerInstance::STOPPED;
267 base::RunLoop run_loop; 269 base::RunLoop run_loop;
268 worker->SendStartWorker(params.Pass(), base::Bind(&SaveStatusAndCall, &status, 270 worker->SendStartWorker(
269 run_loop.QuitClosure()), 271 std::move(params),
270 true, -1, false); 272 base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure()), true, -1,
273 false);
271 run_loop.Run(); 274 run_loop.Run();
272 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); 275 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status);
273 // Don't expect SendStartWorker() to dispatch an OnStopped/Detached() message 276 // Don't expect SendStartWorker() to dispatch an OnStopped/Detached() message
274 // since the worker was already stopped. 277 // since the worker was already stopped.
275 EXPECT_FALSE(stopped_); 278 EXPECT_FALSE(stopped_);
276 EXPECT_FALSE(detached_); 279 EXPECT_FALSE(detached_);
277 280
278 // Repeat, this time have the start callback destroy the worker, as is 281 // Repeat, this time have the start callback destroy the worker, as is
279 // usual when starting a worker fails, and ensure a crash doesn't occur. 282 // usual when starting a worker fails, and ensure a crash doesn't occur.
280 worker->status_ = EmbeddedWorkerInstance::STOPPED; 283 worker->status_ = EmbeddedWorkerInstance::STOPPED;
281 EmbeddedWorkerInstance* worker_ptr = worker.get(); 284 EmbeddedWorkerInstance* worker_ptr = worker.get();
282 worker_ptr->SendStartWorker( 285 worker_ptr->SendStartWorker(
283 params.Pass(), base::Bind(&DestroyWorker, base::Passed(&worker), &status), 286 std::move(params),
284 true, -1, false); 287 base::Bind(&DestroyWorker, base::Passed(&worker), &status), true, -1,
288 false);
285 // No crash. 289 // No crash.
286 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); 290 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status);
287 } 291 }
288 292
289 // Test stopping in the middle of the start worker sequence, before 293 // Test stopping in the middle of the start worker sequence, before
290 // a process is allocated. 294 // a process is allocated.
291 TEST_F(EmbeddedWorkerInstanceTest, StopDuringStart) { 295 TEST_F(EmbeddedWorkerInstanceTest, StopDuringStart) {
292 scoped_ptr<EmbeddedWorkerInstance> worker = 296 scoped_ptr<EmbeddedWorkerInstance> worker =
293 embedded_worker_registry()->CreateWorker(); 297 embedded_worker_registry()->CreateWorker();
294 worker->AddListener(this); 298 worker->AddListener(this);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); 357 base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure()));
354 run_loop.Run(); 358 run_loop.Run();
355 359
356 // The callback should have run, and we should have got an OnStopped message. 360 // The callback should have run, and we should have got an OnStopped message.
357 EXPECT_EQ(SERVICE_WORKER_ERROR_IPC_FAILED, status); 361 EXPECT_EQ(SERVICE_WORKER_ERROR_IPC_FAILED, status);
358 EXPECT_TRUE(stopped_); 362 EXPECT_TRUE(stopped_);
359 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, stopped_old_status_); 363 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, stopped_old_status_);
360 } 364 }
361 365
362 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/embedded_worker_instance.cc ('k') | content/browser/service_worker/embedded_worker_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698