Chromium Code Reviews| 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 "content/renderer/render_thread.h" | 5 #include "content/renderer/render_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) | 382 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) |
| 383 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, | 383 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
| 384 OnSetZoomLevelForCurrentURL) | 384 OnSetZoomLevelForCurrentURL) |
| 385 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 385 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
| 386 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) | 386 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) |
| 387 // TODO(port): removed from render_messages_internal.h; | 387 // TODO(port): removed from render_messages_internal.h; |
| 388 // is there a new non-windows message I should add here? | 388 // is there a new non-windows message I should add here? |
| 389 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 389 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
| 390 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 390 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
| 391 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) | 391 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) |
| 392 IPC_MESSAGE_HANDLER(GpuMsg_GpuChannelEstablished, OnGpuChannelEstablished) | |
| 393 IPC_MESSAGE_UNHANDLED(handled = false) | 392 IPC_MESSAGE_UNHANDLED(handled = false) |
| 394 IPC_END_MESSAGE_MAP() | 393 IPC_END_MESSAGE_MAP() |
| 395 return handled; | 394 return handled; |
| 396 } | 395 } |
| 397 | 396 |
| 398 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 397 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
| 399 // This should only be called at process initialization time, so we shouldn't | 398 // This should only be called at process initialization time, so we shouldn't |
| 400 // have to worry about thread-safety. | 399 // have to worry about thread-safety. |
| 401 RenderView::SetNextPageID(next_page_id); | 400 RenderView::SetNextPageID(next_page_id); |
| 402 } | 401 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 | 457 |
| 459 void RenderThread::ClearPredictorCache() { | 458 void RenderThread::ClearPredictorCache() { |
| 460 int rv; | 459 int rv; |
| 461 Send(new ViewHostMsg_ClearPredictorCache(&rv)); | 460 Send(new ViewHostMsg_ClearPredictorCache(&rv)); |
| 462 } | 461 } |
| 463 | 462 |
| 464 void RenderThread::EnableSpdy(bool enable) { | 463 void RenderThread::EnableSpdy(bool enable) { |
| 465 Send(new ViewHostMsg_EnableSpdy(enable)); | 464 Send(new ViewHostMsg_EnableSpdy(enable)); |
| 466 } | 465 } |
| 467 | 466 |
| 468 void RenderThread::EstablishGpuChannel( | 467 GpuChannelHost* RenderThread::EstablishGpuChannelSync( |
| 469 content::CauseForGpuLaunch cause_for_gpu_launch) { | 468 content::CauseForGpuLaunch cause_for_gpu_launch) { |
| 470 if (gpu_channel_.get()) { | 469 if (gpu_channel_.get()) { |
| 471 // Do nothing if we already have a GPU channel or are already | 470 // Do nothing if we already have a GPU channel or are already |
| 472 // establishing one. | 471 // establishing one. |
| 473 if (gpu_channel_->state() == GpuChannelHost::kUnconnected || | 472 if (gpu_channel_->state() == GpuChannelHost::kUnconnected || |
| 474 gpu_channel_->state() == GpuChannelHost::kConnected) | 473 gpu_channel_->state() == GpuChannelHost::kConnected) |
| 475 return; | 474 return GetGpuChannel(); |
| 476 | 475 |
| 477 // Recreate the channel if it has been lost. | 476 // Recreate the channel if it has been lost. |
| 478 if (gpu_channel_->state() == GpuChannelHost::kLost) | 477 if (gpu_channel_->state() == GpuChannelHost::kLost) |
| 479 gpu_channel_ = NULL; | 478 gpu_channel_ = NULL; |
| 480 } | 479 } |
| 481 | 480 |
| 482 if (!gpu_channel_.get()) | 481 if (!gpu_channel_.get()) |
| 483 gpu_channel_ = new GpuChannelHost; | 482 gpu_channel_ = new GpuChannelHost; |
| 484 | 483 |
| 485 // Ask the browser for the channel name. | 484 // Ask the browser for the channel name. |
| 486 Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch)); | 485 IPC::ChannelHandle channel_handle; |
| 487 } | 486 base::ProcessHandle renderer_process_for_gpu; |
| 487 GPUInfo gpu_info; | |
| 488 if (!Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch, | |
| 489 &channel_handle, | |
| 490 &renderer_process_for_gpu, | |
| 491 &gpu_info)) || | |
| 492 channel_handle.name.empty() || | |
| 493 renderer_process_for_gpu == base::kNullProcessHandle) { | |
| 494 // Otherwise cancel the connection. | |
|
apatrick_chromium
2011/06/08 18:12:36
indentation is out
| |
| 495 gpu_channel_ = NULL; | |
| 496 return NULL; | |
| 497 } | |
| 488 | 498 |
| 489 GpuChannelHost* RenderThread::EstablishGpuChannelSync( | 499 gpu_channel_->set_gpu_info(gpu_info); |
| 490 content::CauseForGpuLaunch cause_for_gpu_launch) { | 500 content::GetContentClient()->SetGpuInfo(gpu_info); |
| 491 EstablishGpuChannel(cause_for_gpu_launch); | 501 |
| 492 Send(new GpuHostMsg_SynchronizeGpu()); | 502 // Connect to the GPU process if a channel name was received. |
| 503 gpu_channel_->Connect(channel_handle, renderer_process_for_gpu); | |
| 504 | |
| 493 return GetGpuChannel(); | 505 return GetGpuChannel(); |
| 494 } | 506 } |
| 495 | 507 |
| 496 GpuChannelHost* RenderThread::GetGpuChannel() { | 508 GpuChannelHost* RenderThread::GetGpuChannel() { |
| 497 if (!gpu_channel_.get()) | 509 if (!gpu_channel_.get()) |
| 498 return NULL; | 510 return NULL; |
| 499 | 511 |
| 500 if (gpu_channel_->state() != GpuChannelHost::kConnected) | 512 if (gpu_channel_->state() != GpuChannelHost::kConnected) |
| 501 return NULL; | 513 return NULL; |
| 502 | 514 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 EnsureWebKitInitialized(); | 652 EnsureWebKitInitialized(); |
| 641 // The call below will cause a GetPlugins call with refresh=true, but at this | 653 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 642 // point we already know that the browser has refreshed its list, so disable | 654 // point we already know that the browser has refreshed its list, so disable |
| 643 // refresh temporarily to prevent each renderer process causing the list to be | 655 // refresh temporarily to prevent each renderer process causing the list to be |
| 644 // regenerated. | 656 // regenerated. |
| 645 plugin_refresh_allowed_ = false; | 657 plugin_refresh_allowed_ = false; |
| 646 WebKit::resetPluginCache(reload_pages); | 658 WebKit::resetPluginCache(reload_pages); |
| 647 plugin_refresh_allowed_ = true; | 659 plugin_refresh_allowed_ = true; |
| 648 } | 660 } |
| 649 | 661 |
| 650 void RenderThread::OnGpuChannelEstablished( | |
| 651 const IPC::ChannelHandle& channel_handle, | |
| 652 base::ProcessHandle renderer_process_for_gpu, | |
| 653 const GPUInfo& gpu_info) { | |
| 654 gpu_channel_->set_gpu_info(gpu_info); | |
| 655 content::GetContentClient()->SetGpuInfo(gpu_info); | |
| 656 | |
| 657 if (!channel_handle.name.empty() && renderer_process_for_gpu != 0) { | |
| 658 // Connect to the GPU process if a channel name was received. | |
| 659 gpu_channel_->Connect(channel_handle, renderer_process_for_gpu); | |
| 660 } else { | |
| 661 // Otherwise cancel the connection. | |
| 662 gpu_channel_ = NULL; | |
| 663 } | |
| 664 } | |
| 665 | |
| 666 scoped_refptr<base::MessageLoopProxy> | 662 scoped_refptr<base::MessageLoopProxy> |
| 667 RenderThread::GetFileThreadMessageLoopProxy() { | 663 RenderThread::GetFileThreadMessageLoopProxy() { |
| 668 DCHECK(message_loop() == MessageLoop::current()); | 664 DCHECK(message_loop() == MessageLoop::current()); |
| 669 if (!file_thread_.get()) { | 665 if (!file_thread_.get()) { |
| 670 file_thread_.reset(new base::Thread("Renderer::FILE")); | 666 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 671 file_thread_->Start(); | 667 file_thread_->Start(); |
| 672 } | 668 } |
| 673 return file_thread_->message_loop_proxy(); | 669 return file_thread_->message_loop_proxy(); |
| 674 } | 670 } |
| 675 | 671 |
| 676 void RenderThread::RegisterExtension(v8::Extension* extension) { | 672 void RenderThread::RegisterExtension(v8::Extension* extension) { |
| 677 WebScriptController::registerExtension(extension); | 673 WebScriptController::registerExtension(extension); |
| 678 v8_extensions_.insert(extension->name()); | 674 v8_extensions_.insert(extension->name()); |
| 679 } | 675 } |
| 680 | 676 |
| 681 bool RenderThread::IsRegisteredExtension( | 677 bool RenderThread::IsRegisteredExtension( |
| 682 const std::string& v8_extension_name) const { | 678 const std::string& v8_extension_name) const { |
| 683 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); | 679 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); |
| 684 } | 680 } |
| OLD | NEW |