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