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

Side by Side Diff: content/browser/service_worker/service_worker_test_utils.h

Issue 2627543002: ServiceWorker: Returns true for IsMojoForServiceWorkerEnabled (Closed)
Patch Set: Created 3 years, 11 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 template <class TestClass>
18 class MojoServiceWorkerTestP : public TestClass,
19 public testing::WithParamInterface<bool> {
20 protected:
21 void SetUp() override {
22 if (!is_mojo_enabled()) {
23 base::CommandLine::ForCurrentProcess()->AppendSwitch(
24 switches::kDisableMojoServiceWorker);
25 }
26 TestClass::SetUp();
27 }
28
29 bool is_mojo_enabled() const { return GetParam(); }
30 };
31
32 template <typename Arg> 17 template <typename Arg>
33 void ReceiveResult(BrowserThread::ID run_quit_thread, 18 void ReceiveResult(BrowserThread::ID run_quit_thread,
34 const base::Closure& quit, 19 const base::Closure& quit,
35 Arg* out, Arg actual) { 20 Arg* out, Arg actual) {
36 *out = actual; 21 *out = actual;
37 if (!quit.is_null()) 22 if (!quit.is_null())
38 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); 23 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit);
39 } 24 }
40 25
41 template <typename Arg> base::Callback<void(Arg)> 26 template <typename Arg> base::Callback<void(Arg)>
42 CreateReceiver(BrowserThread::ID run_quit_thread, 27 CreateReceiver(BrowserThread::ID run_quit_thread,
43 const base::Closure& quit, Arg* out) { 28 const base::Closure& quit, Arg* out) {
44 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out); 29 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out);
45 } 30 }
46 31
47 template <typename Arg> 32 template <typename Arg>
48 base::Callback<void(Arg)> CreateReceiverOnCurrentThread( 33 base::Callback<void(Arg)> CreateReceiverOnCurrentThread(
49 Arg* out, 34 Arg* out,
50 const base::Closure& quit = base::Closure()) { 35 const base::Closure& quit = base::Closure()) {
51 BrowserThread::ID id; 36 BrowserThread::ID id;
52 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); 37 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id);
53 DCHECK(ret); 38 DCHECK(ret);
54 return base::Bind(&ReceiveResult<Arg>, id, quit, out); 39 return base::Bind(&ReceiveResult<Arg>, id, quit, out);
55 } 40 }
56 41
57 } // namespace content 42 } // namespace content
58 43
59 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ 44 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698