| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/service_worker/embedded_worker_registry.h" | 7 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 class ServiceWorkerVersionTest : public testing::Test { | 114 class ServiceWorkerVersionTest : public testing::Test { |
| 115 protected: | 115 protected: |
| 116 ServiceWorkerVersionTest() | 116 ServiceWorkerVersionTest() |
| 117 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 117 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 118 | 118 |
| 119 virtual void SetUp() OVERRIDE { | 119 virtual void SetUp() OVERRIDE { |
| 120 helper_.reset(new MessageReceiver()); | 120 helper_.reset(new MessageReceiver()); |
| 121 | 121 |
| 122 registration_ = new ServiceWorkerRegistration( | 122 registration_ = new ServiceWorkerRegistration( |
| 123 GURL("http://www.example.com/"), | 123 GURL("http://www.example.com/"), |
| 124 1L, |
| 125 helper_->context()->AsWeakPtr()); |
| 126 version_ = new ServiceWorkerVersion( |
| 127 registration_.get(), |
| 124 GURL("http://www.example.com/service_worker.js"), | 128 GURL("http://www.example.com/service_worker.js"), |
| 125 1L, | 129 1L, |
| 126 helper_->context()->AsWeakPtr()); | 130 helper_->context()->AsWeakPtr()); |
| 127 version_ = new ServiceWorkerVersion( | |
| 128 registration_.get(), 1L, helper_->context()->AsWeakPtr()); | |
| 129 | 131 |
| 130 // Simulate adding one process to the worker. | 132 // Simulate adding one process to the worker. |
| 131 int embedded_worker_id = version_->embedded_worker()->embedded_worker_id(); | 133 int embedded_worker_id = version_->embedded_worker()->embedded_worker_id(); |
| 132 helper_->SimulateAddProcessToWorker(embedded_worker_id, kRenderProcessId); | 134 helper_->SimulateAddProcessToWorker(embedded_worker_id, kRenderProcessId); |
| 133 ASSERT_TRUE(version_->HasProcessToRun()); | 135 ASSERT_TRUE(version_->HasProcessToRun()); |
| 134 } | 136 } |
| 135 | 137 |
| 136 virtual void TearDown() OVERRIDE { | 138 virtual void TearDown() OVERRIDE { |
| 137 version_ = 0; | 139 version_ = 0; |
| 138 registration_ = 0; | 140 registration_ = 0; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 NULL)); | 383 NULL)); |
| 382 version_->AddControllee(host.get()); | 384 version_->AddControllee(host.get()); |
| 383 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning()); | 385 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning()); |
| 384 | 386 |
| 385 // The timer should be running if the controllee is removed. | 387 // The timer should be running if the controllee is removed. |
| 386 version_->RemoveControllee(host.get()); | 388 version_->RemoveControllee(host.get()); |
| 387 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); | 389 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); |
| 388 } | 390 } |
| 389 | 391 |
| 390 } // namespace content | 392 } // namespace content |
| OLD | NEW |