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

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

Issue 1264333002: First step to refactor ServiceWorkerVersion to make event dispatching more modular. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rockot nits Created 4 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 "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 template <typename Arg> 14 template <typename Arg>
15 void ReceiveResult(BrowserThread::ID run_quit_thread, 15 void ReceiveResult(BrowserThread::ID run_quit_thread,
16 const base::Closure& quit, 16 const base::Closure& quit,
17 Arg* out, Arg actual) { 17 Arg* out, Arg actual) {
18 *out = actual; 18 *out = actual;
19 if (!quit.is_null()) 19 if (!quit.is_null())
20 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); 20 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit);
21 } 21 }
22 22
23 template <typename Arg> base::Callback<void(Arg)> 23 template <typename Arg> base::Callback<void(Arg)>
24 CreateReceiver(BrowserThread::ID run_quit_thread, 24 CreateReceiver(BrowserThread::ID run_quit_thread,
25 const base::Closure& quit, Arg* out) { 25 const base::Closure& quit, Arg* out) {
26 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out); 26 return base::Bind(&ReceiveResult<Arg>, run_quit_thread, quit, out);
27 } 27 }
28 28
29 template <typename Arg> base::Callback<void(Arg)> 29 template <typename Arg>
30 CreateReceiverOnCurrentThread(Arg* out) { 30 base::Callback<void(Arg)> CreateReceiverOnCurrentThread(
31 Arg* out,
32 const base::Closure& quit = base::Closure()) {
31 BrowserThread::ID id; 33 BrowserThread::ID id;
32 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); 34 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id);
33 DCHECK(ret); 35 DCHECK(ret);
34 return base::Bind(&ReceiveResult<Arg>, id, base::Closure(), out); 36 return base::Bind(&ReceiveResult<Arg>, id, quit, out);
35 } 37 }
36 38
37 } // namespace content 39 } // namespace content
38 40
39 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ 41 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698