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

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

Issue 2787883003: [ServiceWorker] Add EmbeddedWorkerInstanceHost Interface. (Closed)
Patch Set: Refine code comments Created 3 years, 8 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/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 protected: 78 protected:
79 EmbeddedWorkerTestHelper* helper_; 79 EmbeddedWorkerTestHelper* helper_;
80 ~TestingServiceWorkerDispatcherHost() override {} 80 ~TestingServiceWorkerDispatcherHost() override {}
81 }; 81 };
82 82
83 class FailToStartWorkerTestHelper : public EmbeddedWorkerTestHelper { 83 class FailToStartWorkerTestHelper : public EmbeddedWorkerTestHelper {
84 public: 84 public:
85 FailToStartWorkerTestHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} 85 FailToStartWorkerTestHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {}
86 86
87 void OnStartWorker( 87 void OnStartWorker(int embedded_worker_id,
88 int embedded_worker_id, 88 int64_t service_worker_version_id,
89 int64_t service_worker_version_id, 89 const GURL& scope,
90 const GURL& scope, 90 const GURL& script_url,
91 const GURL& script_url, 91 bool pause_after_download,
92 bool pause_after_download, 92 mojom::ServiceWorkerEventDispatcherRequest request,
93 mojom::ServiceWorkerEventDispatcherRequest request) override { 93 mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo
94 EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); 94 instance_host) override {
95 registry()->OnWorkerStopped(worker->process_id(), embedded_worker_id); 95 mojom::EmbeddedWorkerInstanceHostAssociatedPtr instance_host_ptr;
96 instance_host_ptr.Bind(std::move(instance_host));
97 instance_host_ptr->OnStopped();
98 base::RunLoop().RunUntilIdle();
96 } 99 }
97 }; 100 };
98 101
99 class ServiceWorkerDispatcherHostTest : public testing::Test { 102 class ServiceWorkerDispatcherHostTest : public testing::Test {
100 protected: 103 protected:
101 ServiceWorkerDispatcherHostTest() 104 ServiceWorkerDispatcherHostTest()
102 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} 105 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {}
103 106
104 void SetUp() override { 107 void SetUp() override {
105 Initialize(base::MakeUnique<EmbeddedWorkerTestHelper>(base::FilePath())); 108 Initialize(base::MakeUnique<EmbeddedWorkerTestHelper>(base::FilePath()));
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( 834 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse(
832 version_->embedded_worker()->embedded_worker_id(), kFetchEventId, 835 version_->embedded_worker()->embedded_worker_id(), kFetchEventId,
833 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(), 836 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(),
834 base::Time::Now())); 837 base::Time::Now()));
835 838
836 base::RunLoop().RunUntilIdle(); 839 base::RunLoop().RunUntilIdle();
837 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); 840 EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_);
838 } 841 }
839 842
840 } // namespace content 843 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698