OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/browser/browser_message_filter.h" | 5 #include "content/public/browser/browser_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 bool BrowserMessageFilter::OnMessageReceived(const IPC::Message& message) { | 39 bool BrowserMessageFilter::OnMessageReceived(const IPC::Message& message) { |
40 BrowserThread::ID thread = BrowserThread::IO; | 40 BrowserThread::ID thread = BrowserThread::IO; |
41 OverrideThreadForMessage(message, &thread); | 41 OverrideThreadForMessage(message, &thread); |
42 | 42 |
43 if (thread == BrowserThread::IO) { | 43 if (thread == BrowserThread::IO) { |
44 scoped_refptr<base::TaskRunner> runner = | 44 scoped_refptr<base::TaskRunner> runner = |
45 OverrideTaskRunnerForMessage(message); | 45 OverrideTaskRunnerForMessage(message); |
46 if (runner) { | 46 if (runner.get()) { |
47 runner->PostTask(FROM_HERE, | 47 runner->PostTask( |
| 48 FROM_HERE, |
48 base::Bind(base::IgnoreResult(&BrowserMessageFilter::DispatchMessage), | 49 base::Bind(base::IgnoreResult(&BrowserMessageFilter::DispatchMessage), |
49 this, message)); | 50 this, |
| 51 message)); |
50 return true; | 52 return true; |
51 } | 53 } |
52 return DispatchMessage(message); | 54 return DispatchMessage(message); |
53 } | 55 } |
54 | 56 |
55 if (thread == BrowserThread::UI && !CheckCanDispatchOnUI(message, this)) | 57 if (thread == BrowserThread::UI && !CheckCanDispatchOnUI(message, this)) |
56 return true; | 58 return true; |
57 | 59 |
58 BrowserThread::PostTask( | 60 BrowserThread::PostTask( |
59 thread, FROM_HERE, | 61 thread, FROM_HERE, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 "Must handle messages that were dispatched to another thread!"; | 140 "Must handle messages that were dispatched to another thread!"; |
139 if (!message_was_ok) { | 141 if (!message_was_ok) { |
140 content::RecordAction(UserMetricsAction("BadMessageTerminate_BMF")); | 142 content::RecordAction(UserMetricsAction("BadMessageTerminate_BMF")); |
141 BadMessageReceived(); | 143 BadMessageReceived(); |
142 } | 144 } |
143 | 145 |
144 return rv; | 146 return rv; |
145 } | 147 } |
146 | 148 |
147 } // namespace content | 149 } // namespace content |
OLD | NEW |