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

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

Issue 2871523002: Use OnceCallback on Mojo interfaces in //content (Closed)
Patch Set: . Created 3 years, 7 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/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
14 #include "base/test/simple_test_tick_clock.h" 15 #include "base/test/simple_test_tick_clock.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "content/browser/service_worker/embedded_worker_registry.h" 17 #include "content/browser/service_worker/embedded_worker_registry.h"
17 #include "content/browser/service_worker/embedded_worker_status.h" 18 #include "content/browser/service_worker/embedded_worker_status.h"
18 #include "content/browser/service_worker/embedded_worker_test_helper.h" 19 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 base::TimeDelta::FromSeconds(1); 125 base::TimeDelta::FromSeconds(1);
125 } 126 }
126 127
127 class TestServiceImpl : public mojom::TestService { 128 class TestServiceImpl : public mojom::TestService {
128 public: 129 public:
129 static void Create(mojo::InterfaceRequest<mojom::TestService> request) { 130 static void Create(mojo::InterfaceRequest<mojom::TestService> request) {
130 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl), 131 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl),
131 std::move(request)); 132 std::move(request));
132 } 133 }
133 134
134 void DoSomething(const DoSomethingCallback& callback) override { 135 void DoSomething(DoSomethingCallback callback) override {
135 callback.Run(); 136 std::move(callback).Run();
136 } 137 }
137 138
138 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { 139 void DoTerminateProcess(DoTerminateProcessCallback callback) override {
139 NOTREACHED(); 140 NOTREACHED();
140 } 141 }
141 142
142 void CreateFolder(const CreateFolderCallback& callback) override { 143 void CreateFolder(CreateFolderCallback callback) override { NOTREACHED(); }
144
145 void GetRequestorName(GetRequestorNameCallback callback) override {
146 std::move(callback).Run("");
147 }
148
149 void CreateSharedBuffer(const std::string& message,
150 CreateSharedBufferCallback callback) override {
143 NOTREACHED(); 151 NOTREACHED();
144 } 152 }
145 153
146 void GetRequestorName(const GetRequestorNameCallback& callback) override {
147 callback.Run("");
148 }
149
150 void CreateSharedBuffer(const std::string& message,
151 const CreateSharedBufferCallback& callback) override {
152 NOTREACHED();
153 }
154
155 private: 154 private:
156 explicit TestServiceImpl() {} 155 explicit TestServiceImpl() {}
157 }; 156 };
158 157
159 } // namespace 158 } // namespace
160 159
161 class ServiceWorkerVersionTest : public testing::Test { 160 class ServiceWorkerVersionTest : public testing::Test {
162 protected: 161 protected:
163 struct RunningStateListener : public ServiceWorkerVersion::Listener { 162 struct RunningStateListener : public ServiceWorkerVersion::Listener {
164 RunningStateListener() : last_status(EmbeddedWorkerStatus::STOPPED) {} 163 RunningStateListener() : last_status(EmbeddedWorkerStatus::STOPPED) {}
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 // OnStarted. 1440 // OnStarted.
1442 version_->StopWorker(CreateReceiverOnCurrentThread(&status2)); 1441 version_->StopWorker(CreateReceiverOnCurrentThread(&status2));
1443 base::RunLoop().RunUntilIdle(); 1442 base::RunLoop().RunUntilIdle();
1444 1443
1445 EXPECT_EQ(SERVICE_WORKER_OK, status1); 1444 EXPECT_EQ(SERVICE_WORKER_OK, status1);
1446 EXPECT_EQ(SERVICE_WORKER_OK, status2); 1445 EXPECT_EQ(SERVICE_WORKER_OK, status2);
1447 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version_->running_status()); 1446 EXPECT_EQ(EmbeddedWorkerStatus::RUNNING, version_->running_status());
1448 } 1447 }
1449 1448
1450 } // namespace content 1449 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_associated_interface_unittest.cc ('k') | content/browser/webui/web_ui_mojo_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698