| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/chrome_v8_extension_handler.h" | 5 #include "chrome/renderer/extensions/chrome_v8_extension_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/renderer/extensions/chrome_v8_context.h" | 8 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/common/view_messages.h" | |
| 11 | 10 |
| 12 using content::RenderThread; | 11 using content::RenderThread; |
| 13 | 12 |
| 14 ChromeV8ExtensionHandler::ChromeV8ExtensionHandler(ChromeV8Context* context) | 13 ChromeV8ExtensionHandler::ChromeV8ExtensionHandler(ChromeV8Context* context) |
| 15 : context_(context), routing_id_(MSG_ROUTING_NONE) { | 14 : context_(context), routing_id_(MSG_ROUTING_NONE) { |
| 16 } | 15 } |
| 17 | 16 |
| 18 ChromeV8ExtensionHandler::~ChromeV8ExtensionHandler() { | 17 ChromeV8ExtensionHandler::~ChromeV8ExtensionHandler() { |
| 19 if (routing_id_ != MSG_ROUTING_NONE) | 18 if (routing_id_ != MSG_ROUTING_NONE) |
| 20 RenderThread::Get()->RemoveRoute(routing_id_); | 19 RenderThread::Get()->RemoveRoute(routing_id_); |
| 21 } | 20 } |
| 22 | 21 |
| 23 int ChromeV8ExtensionHandler::GetRoutingId() { | 22 int ChromeV8ExtensionHandler::GetRoutingId() { |
| 24 if (routing_id_ == MSG_ROUTING_NONE) { | 23 if (routing_id_ == MSG_ROUTING_NONE) { |
| 25 RenderThread* render_thread = RenderThread::Get(); | 24 routing_id_ = RenderThread::Get()->GenerateRoutingID(); |
| 26 CHECK(render_thread); | 25 RenderThread::Get()->AddRoute(routing_id_, this); |
| 27 render_thread->Send(new ViewHostMsg_GenerateRoutingID(&routing_id_)); | |
| 28 render_thread->AddRoute(routing_id_, this); | |
| 29 } | 26 } |
| 30 | 27 |
| 31 return routing_id_; | 28 return routing_id_; |
| 32 } | 29 } |
| 33 | 30 |
| 34 void ChromeV8ExtensionHandler::Send(IPC::Message* message) { | 31 void ChromeV8ExtensionHandler::Send(IPC::Message* message) { |
| 35 RenderThread::Get()->Send(message); | 32 RenderThread::Get()->Send(message); |
| 36 } | 33 } |
| OLD | NEW |