| 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/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // Intentionally hang upon the request of the browser. | 481 // Intentionally hang upon the request of the browser. |
| 482 for (;;) | 482 for (;;) |
| 483 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 483 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 484 } | 484 } |
| 485 | 485 |
| 486 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, | 486 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, |
| 487 int renderer_child_id, | 487 int renderer_child_id, |
| 488 bool incognito, | 488 bool incognito, |
| 489 IPC::ChannelHandle* handle) { | 489 IPC::ChannelHandle* handle) { |
| 490 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 490 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
| 491 IPC::ChannelHandle plugin_handle; | 491 mojo::MessagePipe pipe; |
| 492 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID( | |
| 493 base::StringPrintf( | |
| 494 "%d.r%d", base::GetCurrentProcId(), renderer_child_id)); | |
| 495 | 492 |
| 496 ppapi::proxy::ProxyChannel* dispatcher = NULL; | 493 ppapi::proxy::ProxyChannel* dispatcher = NULL; |
| 497 bool init_result = false; | 494 bool init_result = false; |
| 498 if (is_broker_) { | 495 if (is_broker_) { |
| 499 bool peer_is_browser = renderer_pid == base::kNullProcessId; | 496 bool peer_is_browser = renderer_pid == base::kNullProcessId; |
| 500 BrokerProcessDispatcher* broker_dispatcher = | 497 BrokerProcessDispatcher* broker_dispatcher = |
| 501 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, | 498 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, |
| 502 connect_instance_func_, peer_is_browser); | 499 connect_instance_func_, peer_is_browser); |
| 503 init_result = broker_dispatcher->InitBrokerWithChannel(this, | 500 init_result = broker_dispatcher->InitBrokerWithChannel( |
| 504 renderer_pid, | 501 this, renderer_pid, pipe.handle0.release(), false); |
| 505 plugin_handle, | |
| 506 false); | |
| 507 dispatcher = broker_dispatcher; | 502 dispatcher = broker_dispatcher; |
| 508 } else { | 503 } else { |
| 509 DCHECK_NE(base::kNullProcessId, renderer_pid); | 504 DCHECK_NE(base::kNullProcessId, renderer_pid); |
| 510 PluginProcessDispatcher* plugin_dispatcher = | 505 PluginProcessDispatcher* plugin_dispatcher = |
| 511 new PluginProcessDispatcher(plugin_entry_points_.get_interface, | 506 new PluginProcessDispatcher(plugin_entry_points_.get_interface, |
| 512 permissions_, | 507 permissions_, |
| 513 incognito); | 508 incognito); |
| 514 init_result = plugin_dispatcher->InitPluginWithChannel(this, | 509 init_result = plugin_dispatcher->InitPluginWithChannel( |
| 515 renderer_pid, | 510 this, renderer_pid, pipe.handle0.release(), false); |
| 516 plugin_handle, | |
| 517 false); | |
| 518 dispatcher = plugin_dispatcher; | 511 dispatcher = plugin_dispatcher; |
| 519 } | 512 } |
| 520 | 513 |
| 521 if (!init_result) { | 514 if (!init_result) { |
| 522 delete dispatcher; | 515 delete dispatcher; |
| 523 return false; | 516 return false; |
| 524 } | 517 } |
| 525 | 518 *handle = pipe.handle1.release(); |
| 526 handle->name = plugin_handle.name; | |
| 527 #if defined(OS_POSIX) | |
| 528 // On POSIX, transfer ownership of the renderer-side (client) FD. | |
| 529 // This ensures this process will be notified when it is closed even if a | |
| 530 // connection is not established. | |
| 531 handle->socket = base::FileDescriptor(dispatcher->TakeRendererFD()); | |
| 532 if (handle->socket.fd == -1) | |
| 533 return false; | |
| 534 #endif | |
| 535 | 519 |
| 536 // From here, the dispatcher will manage its own lifetime according to the | 520 // From here, the dispatcher will manage its own lifetime according to the |
| 537 // lifetime of the attached channel. | 521 // lifetime of the attached channel. |
| 538 return true; | 522 return true; |
| 539 } | 523 } |
| 540 | 524 |
| 541 void PpapiThread::SavePluginName(const base::FilePath& path) { | 525 void PpapiThread::SavePluginName(const base::FilePath& path) { |
| 542 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 526 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
| 543 path.BaseName().AsUTF8Unsafe()); | 527 path.BaseName().AsUTF8Unsafe()); |
| 544 } | 528 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 GetHistogramName(is_broker_, "LoadTime", path), | 571 GetHistogramName(is_broker_, "LoadTime", path), |
| 588 base::TimeDelta::FromMilliseconds(1), | 572 base::TimeDelta::FromMilliseconds(1), |
| 589 base::TimeDelta::FromSeconds(10), | 573 base::TimeDelta::FromSeconds(10), |
| 590 50, | 574 50, |
| 591 base::HistogramBase::kUmaTargetedHistogramFlag); | 575 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 592 | 576 |
| 593 histogram->AddTime(load_time); | 577 histogram->AddTime(load_time); |
| 594 } | 578 } |
| 595 | 579 |
| 596 } // namespace content | 580 } // namespace content |
| OLD | NEW |