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 "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 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 }; | 156 }; |
157 | 157 |
158 base::Time GetYesterday() { | 158 base::Time GetYesterday() { |
159 return base::Time::Now() - base::TimeDelta::FromDays(1) - | 159 return base::Time::Now() - base::TimeDelta::FromDays(1) - |
160 base::TimeDelta::FromSeconds(1); | 160 base::TimeDelta::FromSeconds(1); |
161 } | 161 } |
162 | 162 |
163 class TestMojoServiceImpl : public mojom::TestMojoService { | 163 class TestMojoServiceImpl : public mojom::TestMojoService { |
164 public: | 164 public: |
165 static void Create(mojo::InterfaceRequest<mojom::TestMojoService> request) { | 165 static void Create(mojo::InterfaceRequest<mojom::TestMojoService> request) { |
166 new TestMojoServiceImpl(std::move(request)); | 166 mojo::MakeStrongBinding(base::WrapUnique(new TestMojoServiceImpl), |
| 167 std::move(request)); |
167 } | 168 } |
168 | 169 |
169 void DoSomething(const DoSomethingCallback& callback) override { | 170 void DoSomething(const DoSomethingCallback& callback) override { |
170 callback.Run(); | 171 callback.Run(); |
171 } | 172 } |
172 | 173 |
173 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { | 174 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { |
174 NOTREACHED(); | 175 NOTREACHED(); |
175 } | 176 } |
176 | 177 |
177 void CreateFolder(const CreateFolderCallback& callback) override { | 178 void CreateFolder(const CreateFolderCallback& callback) override { |
178 NOTREACHED(); | 179 NOTREACHED(); |
179 } | 180 } |
180 | 181 |
181 void GetRequestorName(const GetRequestorNameCallback& callback) override { | 182 void GetRequestorName(const GetRequestorNameCallback& callback) override { |
182 callback.Run(mojo::String("")); | 183 callback.Run(mojo::String("")); |
183 } | 184 } |
184 | 185 |
185 private: | 186 private: |
186 explicit TestMojoServiceImpl( | 187 explicit TestMojoServiceImpl() {} |
187 mojo::InterfaceRequest<mojom::TestMojoService> request) | |
188 : binding_(this, std::move(request)) {} | |
189 | |
190 mojo::StrongBinding<mojom::TestMojoService> binding_; | |
191 }; | 188 }; |
192 | 189 |
193 } // namespace | 190 } // namespace |
194 | 191 |
195 class ServiceWorkerVersionTest : public testing::Test { | 192 class ServiceWorkerVersionTest : public testing::Test { |
196 protected: | 193 protected: |
197 struct RunningStateListener : public ServiceWorkerVersion::Listener { | 194 struct RunningStateListener : public ServiceWorkerVersion::Listener { |
198 RunningStateListener() : last_status(EmbeddedWorkerStatus::STOPPED) {} | 195 RunningStateListener() : last_status(EmbeddedWorkerStatus::STOPPED) {} |
199 ~RunningStateListener() override {} | 196 ~RunningStateListener() override {} |
200 void OnRunningStateChanged(ServiceWorkerVersion* version) override { | 197 void OnRunningStateChanged(ServiceWorkerVersion* version) override { |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); | 1734 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); |
1738 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0); | 1735 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0); |
1739 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1736 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1740 StopWorker(); | 1737 StopWorker(); |
1741 // The UMA for kLinkMouseDown must be recorded when the worker stopped. | 1738 // The UMA for kLinkMouseDown must be recorded when the worker stopped. |
1742 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); | 1739 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); |
1743 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1); | 1740 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1); |
1744 } | 1741 } |
1745 | 1742 |
1746 } // namespace content | 1743 } // namespace content |
OLD | NEW |