| 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 "ppapi/host/resource_message_filter.h" | 5 #include "ppapi/host/resource_message_filter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ResourceMessageFilter::OnFilterDestroyed() { | 56 void ResourceMessageFilter::OnFilterDestroyed() { |
| 57 resource_host_ = NULL; | 57 resource_host_ = NULL; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool ResourceMessageFilter::HandleMessage(const IPC::Message& msg, | 60 bool ResourceMessageFilter::HandleMessage(const IPC::Message& msg, |
| 61 HostMessageContext* context) { | 61 HostMessageContext* context) { |
| 62 scoped_refptr<base::TaskRunner> runner = OverrideTaskRunnerForMessage(msg); | 62 scoped_refptr<base::TaskRunner> runner = OverrideTaskRunnerForMessage(msg); |
| 63 if (runner.get()) { | 63 if (runner.get()) { |
| 64 if (runner->RunsTasksOnCurrentThread()) { | 64 if (runner->RunsTasksInCurrentSequence()) { |
| 65 DispatchMessage(msg, *context); | 65 DispatchMessage(msg, *context); |
| 66 } else { | 66 } else { |
| 67 // TODO(raymes): We need to make a copy so the context can be used on | 67 // TODO(raymes): We need to make a copy so the context can be used on |
| 68 // other threads. It would be better to have a thread-safe refcounted | 68 // other threads. It would be better to have a thread-safe refcounted |
| 69 // context. | 69 // context. |
| 70 HostMessageContext context_copy = *context; | 70 HostMessageContext context_copy = *context; |
| 71 runner->PostTask(FROM_HERE, base::Bind( | 71 runner->PostTask(FROM_HERE, base::Bind( |
| 72 &ResourceMessageFilter::DispatchMessage, this, msg, context_copy)); | 72 &ResourceMessageFilter::DispatchMessage, this, msg, context_copy)); |
| 73 } | 73 } |
| 74 return true; | 74 return true; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 return NULL; | 94 return NULL; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, | 97 void ResourceMessageFilter::DispatchMessage(const IPC::Message& msg, |
| 98 HostMessageContext context) { | 98 HostMessageContext context) { |
| 99 RunMessageHandlerAndReply(msg, &context); | 99 RunMessageHandlerAndReply(msg, &context); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace host | 102 } // namespace host |
| 103 } // namespace ppapi | 103 } // namespace ppapi |
| OLD | NEW |