| 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 "chrome/renderer/chrome_mock_render_thread.h" | 5 #include "chrome/renderer/chrome_mock_render_thread.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "extensions/features/features.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 #if defined(ENABLE_EXTENSIONS) | 11 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 11 #include "extensions/common/extension_messages.h" | 12 #include "extensions/common/extension_messages.h" |
| 12 #endif | 13 #endif |
| 13 | 14 |
| 14 ChromeMockRenderThread::ChromeMockRenderThread() { | 15 ChromeMockRenderThread::ChromeMockRenderThread() { |
| 15 } | 16 } |
| 16 | 17 |
| 17 ChromeMockRenderThread::~ChromeMockRenderThread() { | 18 ChromeMockRenderThread::~ChromeMockRenderThread() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 scoped_refptr<base::SingleThreadTaskRunner> | 21 scoped_refptr<base::SingleThreadTaskRunner> |
| 21 ChromeMockRenderThread::GetIOTaskRunner() { | 22 ChromeMockRenderThread::GetIOTaskRunner() { |
| 22 return io_task_runner_; | 23 return io_task_runner_; |
| 23 } | 24 } |
| 24 | 25 |
| 25 void ChromeMockRenderThread::set_io_task_runner( | 26 void ChromeMockRenderThread::set_io_task_runner( |
| 26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 27 io_task_runner_ = task_runner; | 28 io_task_runner_ = task_runner; |
| 28 } | 29 } |
| 29 | 30 |
| 30 bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { | 31 bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { |
| 31 if (content::MockRenderThread::OnMessageReceived(msg)) | 32 if (content::MockRenderThread::OnMessageReceived(msg)) |
| 32 return true; | 33 return true; |
| 33 | 34 |
| 34 // Some messages we do special handling. | 35 // Some messages we do special handling. |
| 35 #if defined(ENABLE_EXTENSIONS) | 36 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 36 bool handled = true; | 37 bool handled = true; |
| 37 IPC_BEGIN_MESSAGE_MAP(ChromeMockRenderThread, msg) | 38 IPC_BEGIN_MESSAGE_MAP(ChromeMockRenderThread, msg) |
| 38 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, | 39 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, |
| 39 OnOpenChannelToExtension) | 40 OnOpenChannelToExtension) |
| 40 IPC_MESSAGE_UNHANDLED(handled = false) | 41 IPC_MESSAGE_UNHANDLED(handled = false) |
| 41 IPC_END_MESSAGE_MAP() | 42 IPC_END_MESSAGE_MAP() |
| 42 return handled; | 43 return handled; |
| 43 #else | 44 #else |
| 44 return false; | 45 return false; |
| 45 #endif | 46 #endif |
| 46 } | 47 } |
| 47 | 48 |
| 48 #if defined(ENABLE_EXTENSIONS) | 49 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 49 void ChromeMockRenderThread::OnOpenChannelToExtension( | 50 void ChromeMockRenderThread::OnOpenChannelToExtension( |
| 50 int routing_id, | 51 int routing_id, |
| 51 const ExtensionMsg_ExternalConnectionInfo& info, | 52 const ExtensionMsg_ExternalConnectionInfo& info, |
| 52 const std::string& channel_name, | 53 const std::string& channel_name, |
| 53 bool include_tls_channel_id, | 54 bool include_tls_channel_id, |
| 54 int request_id) { | 55 int request_id) { |
| 55 Send(new ExtensionMsg_AssignPortId(routing_id, 0, request_id)); | 56 Send(new ExtensionMsg_AssignPortId(routing_id, 0, request_id)); |
| 56 } | 57 } |
| 57 #endif | 58 #endif |
| OLD | NEW |