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

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

Issue 2436223004: Use the serviceworker with mojo by default (Closed)
Patch Set: Rebase Created 4 years, 1 month 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> 17 template <class TestClass>
18 class MojoServiceWorkerTestP : public TestClass, 18 class MojoServiceWorkerTestP : public TestClass,
19 public testing::WithParamInterface<bool> { 19 public testing::WithParamInterface<bool> {
20 protected: 20 protected:
21 void SetUp() override { 21 void SetUp() override {
22 is_mojo_enabled_ = GetParam(); 22 if (!is_mojo_enabled()) {
23 if (is_mojo_enabled()) {
24 base::CommandLine::ForCurrentProcess()->AppendSwitch( 23 base::CommandLine::ForCurrentProcess()->AppendSwitch(
25 switches::kMojoServiceWorker); 24 switches::kDisableMojoServiceWorker);
26 } 25 }
27 TestClass::SetUp(); 26 TestClass::SetUp();
28 } 27 }
29 28
30 bool is_mojo_enabled() const { return is_mojo_enabled_; } 29 bool is_mojo_enabled() const { return GetParam(); }
31
32 private:
33 bool is_mojo_enabled_ = false;
34 }; 30 };
35 31
36 template <typename Arg> 32 template <typename Arg>
37 void ReceiveResult(BrowserThread::ID run_quit_thread, 33 void ReceiveResult(BrowserThread::ID run_quit_thread,
38 const base::Closure& quit, 34 const base::Closure& quit,
39 Arg* out, Arg actual) { 35 Arg* out, Arg actual) {
40 *out = actual; 36 *out = actual;
41 if (!quit.is_null()) 37 if (!quit.is_null())
42 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); 38 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit);
43 } 39 }
(...skipping 10 matching lines...) Expand all
54 const base::Closure& quit = base::Closure()) { 50 const base::Closure& quit = base::Closure()) {
55 BrowserThread::ID id; 51 BrowserThread::ID id;
56 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); 52 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id);
57 DCHECK(ret); 53 DCHECK(ret);
58 return base::Bind(&ReceiveResult<Arg>, id, quit, out); 54 return base::Bind(&ReceiveResult<Arg>, id, quit, out);
59 } 55 }
60 56
61 } // namespace content 57 } // namespace content
62 58
63 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ 59 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698