| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 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 "ppapi/proxy/broker_dispatcher.h" | 5 #include "ppapi/proxy/broker_dispatcher.h" | 
| 6 | 6 | 
| 7 #include "base/sync_socket.h" | 7 #include "base/sync_socket.h" | 
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" | 
| 9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" | 
| 10 #include "ppapi/shared_impl/platform_file.h" | 10 #include "ppapi/shared_impl/platform_file.h" | 
| 11 | 11 | 
| 12 namespace ppapi { | 12 namespace ppapi { | 
| 13 namespace proxy { | 13 namespace proxy { | 
| 14 | 14 | 
| 15 BrokerDispatcher::BrokerDispatcher(base::ProcessHandle remote_process_handle, | 15 BrokerDispatcher::BrokerDispatcher(PP_ConnectInstance_Func connect_instance) | 
| 16                                    PP_ConnectInstance_Func connect_instance) | 16     : connect_instance_(connect_instance) { | 
| 17     : ProxyChannel(remote_process_handle), |  | 
| 18       connect_instance_(connect_instance) { |  | 
| 19 } | 17 } | 
| 20 | 18 | 
| 21 BrokerDispatcher::~BrokerDispatcher() { | 19 BrokerDispatcher::~BrokerDispatcher() { | 
| 22 } | 20 } | 
| 23 | 21 | 
| 24 bool BrokerDispatcher::InitBrokerWithChannel( | 22 bool BrokerDispatcher::InitBrokerWithChannel( | 
| 25     ProxyChannel::Delegate* delegate, | 23     ProxyChannel::Delegate* delegate, | 
| 26     const IPC::ChannelHandle& channel_handle, | 24     const IPC::ChannelHandle& channel_handle, | 
| 27     bool is_client) { | 25     bool is_client) { | 
| 28   return ProxyChannel::InitWithChannel(delegate, channel_handle, is_client); | 26   return ProxyChannel::InitWithChannel(delegate, channel_handle, is_client); | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 58     } else { | 56     } else { | 
| 59       *result = PP_ERROR_FAILED; | 57       *result = PP_ERROR_FAILED; | 
| 60       // Close the handle since there is no other owner. | 58       // Close the handle since there is no other owner. | 
| 61       // The easiest way to clean it up is to just put it in an object | 59       // The easiest way to clean it up is to just put it in an object | 
| 62       // and then close them. This failure case is not performance critical. | 60       // and then close them. This failure case is not performance critical. | 
| 63       base::SyncSocket temp_socket(socket_handle); | 61       base::SyncSocket temp_socket(socket_handle); | 
| 64     } | 62     } | 
| 65   } | 63   } | 
| 66 } | 64 } | 
| 67 | 65 | 
| 68 BrokerHostDispatcher::BrokerHostDispatcher( | 66 BrokerHostDispatcher::BrokerHostDispatcher() | 
| 69     base::ProcessHandle remote_process_handle) | 67     : BrokerDispatcher(NULL) { | 
| 70     : BrokerDispatcher(remote_process_handle, NULL) { |  | 
| 71 } | 68 } | 
| 72 | 69 | 
| 73 void BrokerHostDispatcher::OnChannelError() { | 70 void BrokerHostDispatcher::OnChannelError() { | 
| 74   DVLOG(1) << "BrokerHostDispatcher::OnChannelError()"; | 71   DVLOG(1) << "BrokerHostDispatcher::OnChannelError()"; | 
| 75   BrokerDispatcher::OnChannelError();  // Stop using the channel. | 72   BrokerDispatcher::OnChannelError();  // Stop using the channel. | 
| 76 | 73 | 
| 77   // Tell the host about the crash so it can clean up and display notification. | 74   // Tell the host about the crash so it can clean up and display notification. | 
| 78   // TODO(ddorwin): Add BrokerCrashed() to PPB_Proxy_Private and call it. | 75   // TODO(ddorwin): Add BrokerCrashed() to PPB_Proxy_Private and call it. | 
| 79   // ppb_proxy_->BrokerCrashed(pp_module()); | 76   // ppb_proxy_->BrokerCrashed(pp_module()); | 
| 80 } | 77 } | 
| 81 | 78 | 
| 82 BrokerSideDispatcher::BrokerSideDispatcher( | 79 BrokerSideDispatcher::BrokerSideDispatcher( | 
| 83     base::ProcessHandle remote_process_handle, |  | 
| 84     PP_ConnectInstance_Func connect_instance) | 80     PP_ConnectInstance_Func connect_instance) | 
| 85     : BrokerDispatcher(remote_process_handle, connect_instance) { | 81     : BrokerDispatcher(connect_instance) { | 
| 86 } | 82 } | 
| 87 | 83 | 
| 88 void BrokerSideDispatcher::OnChannelError() { | 84 void BrokerSideDispatcher::OnChannelError() { | 
| 89   DVLOG(1) << "BrokerSideDispatcher::OnChannelError()"; | 85   DVLOG(1) << "BrokerSideDispatcher::OnChannelError()"; | 
| 90   BrokerDispatcher::OnChannelError(); | 86   BrokerDispatcher::OnChannelError(); | 
| 91 | 87 | 
| 92   // The renderer has crashed or exited. This channel and all instances | 88   // The renderer has crashed or exited. This channel and all instances | 
| 93   // associated with it are no longer valid. | 89   // associated with it are no longer valid. | 
| 94   // TODO(ddorwin): This causes the broker process to exit, which may not be | 90   // TODO(ddorwin): This causes the broker process to exit, which may not be | 
| 95   // desirable in some use cases. | 91   // desirable in some use cases. | 
| 96   delete this; | 92   delete this; | 
| 97 } | 93 } | 
| 98 | 94 | 
| 99 | 95 | 
| 100 }  // namespace proxy | 96 }  // namespace proxy | 
| 101 }  // namespace ppapi | 97 }  // namespace ppapi | 
| OLD | NEW | 
|---|