OLD | NEW |
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" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); | 146 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); |
147 }; | 147 }; |
148 | 148 |
149 // A helper to simulate the start worker sequence is stalled in a worker | 149 // A helper to simulate the start worker sequence is stalled in a worker |
150 // process. | 150 // process. |
151 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { | 151 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { |
152 public: | 152 public: |
153 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} | 153 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} |
154 ~StalledInStartWorkerHelper() override{}; | 154 ~StalledInStartWorkerHelper() override{}; |
155 | 155 |
156 void OnStartWorker(int embedded_worker_id, | 156 void OnStartWorker( |
157 int64_t service_worker_version_id, | 157 int embedded_worker_id, |
158 const GURL& scope, | 158 int64_t service_worker_version_id, |
159 const GURL& script_url, | 159 const GURL& scope, |
160 bool pause_after_download) override { | 160 const GURL& script_url, |
| 161 bool pause_after_download, |
| 162 mojom::ServiceWorkerEventDispatcherRequest request) override { |
161 if (force_stall_in_start_) { | 163 if (force_stall_in_start_) { |
162 // Do nothing to simulate a stall in the worker process. | 164 // Do nothing to simulate a stall in the worker process. |
163 return; | 165 return; |
164 } | 166 } |
165 EmbeddedWorkerTestHelper::OnStartWorker(embedded_worker_id, | 167 EmbeddedWorkerTestHelper::OnStartWorker( |
166 service_worker_version_id, scope, | 168 embedded_worker_id, service_worker_version_id, scope, script_url, |
167 script_url, pause_after_download); | 169 pause_after_download, std::move(request)); |
168 } | 170 } |
169 | 171 |
170 void set_force_stall_in_start(bool force_stall_in_start) { | 172 void set_force_stall_in_start(bool force_stall_in_start) { |
171 force_stall_in_start_ = force_stall_in_start; | 173 force_stall_in_start_ = force_stall_in_start; |
172 } | 174 } |
173 | 175 |
174 private: | 176 private: |
175 bool force_stall_in_start_ = true; | 177 bool force_stall_in_start_ = true; |
176 }; | 178 }; |
177 | 179 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 719 |
718 // Worker should handle the sudden shutdown as detach. | 720 // Worker should handle the sudden shutdown as detach. |
719 ASSERT_EQ(3u, events_.size()); | 721 ASSERT_EQ(3u, events_.size()); |
720 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type); | 722 EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type); |
721 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); | 723 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); |
722 EXPECT_EQ(DETACHED, events_[2].type); | 724 EXPECT_EQ(DETACHED, events_[2].type); |
723 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); | 725 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); |
724 } | 726 } |
725 | 727 |
726 } // namespace content | 728 } // namespace content |
OLD | NEW |