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

Side by Side Diff: extensions/browser/api/async_api_function.cc

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/api/dns/dns_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/api/async_api_function.h" 5 #include "extensions/browser/api/async_api_function.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "extensions/browser/extension_system.h" 8 #include "extensions/browser/extension_system.h"
9 9
10 using content::BrowserThread; 10 using content::BrowserThread;
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 // AsyncApiFunction 14 // AsyncApiFunction
15 AsyncApiFunction::AsyncApiFunction() : work_thread_id_(BrowserThread::IO) {} 15 AsyncApiFunction::AsyncApiFunction() : work_thread_id_(BrowserThread::IO) {}
16 16
17 AsyncApiFunction::~AsyncApiFunction() {} 17 AsyncApiFunction::~AsyncApiFunction() {}
18 18
19 bool AsyncApiFunction::RunImpl() { 19 bool AsyncApiFunction::RunImpl() {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 20 DCHECK_CURRENTLY_ON(BrowserThread::UI);
21 21
22 if (!PrePrepare() || !Prepare()) { 22 if (!PrePrepare() || !Prepare()) {
23 return false; 23 return false;
24 } 24 }
25 bool rv = BrowserThread::PostTask( 25 bool rv = BrowserThread::PostTask(
26 work_thread_id_, 26 work_thread_id_,
27 FROM_HERE, 27 FROM_HERE,
28 base::Bind(&AsyncApiFunction::WorkOnWorkThread, this)); 28 base::Bind(&AsyncApiFunction::WorkOnWorkThread, this));
29 DCHECK(rv); 29 DCHECK(rv);
30 return true; 30 return true;
(...skipping 14 matching lines...) Expand all
45 BrowserThread::UI, 45 BrowserThread::UI,
46 FROM_HERE, 46 FROM_HERE,
47 base::Bind(&AsyncApiFunction::RespondOnUIThread, this)); 47 base::Bind(&AsyncApiFunction::RespondOnUIThread, this));
48 DCHECK(rv); 48 DCHECK(rv);
49 } else { 49 } else {
50 SendResponse(Respond()); 50 SendResponse(Respond());
51 } 51 }
52 } 52 }
53 53
54 void AsyncApiFunction::WorkOnWorkThread() { 54 void AsyncApiFunction::WorkOnWorkThread() {
55 DCHECK(BrowserThread::CurrentlyOn(work_thread_id_)); 55 DCHECK_CURRENTLY_ON(work_thread_id_);
56 DLOG_IF(ERROR, (work_thread_id_ == BrowserThread::UI)) 56 DLOG_IF(ERROR, (work_thread_id_ == BrowserThread::UI))
57 << "You have specified that AsyncApiFunction::Work() should happen on " 57 << "You have specified that AsyncApiFunction::Work() should happen on "
58 "the UI thread. This nullifies the point of this class. Either " 58 "the UI thread. This nullifies the point of this class. Either "
59 "specify a different thread or derive from a different class."; 59 "specify a different thread or derive from a different class.";
60 AsyncWorkStart(); 60 AsyncWorkStart();
61 } 61 }
62 62
63 void AsyncApiFunction::RespondOnUIThread() { 63 void AsyncApiFunction::RespondOnUIThread() {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK_CURRENTLY_ON(BrowserThread::UI);
65 SendResponse(Respond()); 65 SendResponse(Respond());
66 } 66 }
67 67
68 } // namespace extensions 68 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/api/dns/dns_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698