| 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 "webkit/plugins/ppapi/ppb_broker_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/shared_impl/platform_file.h" | 8 #include "ppapi/shared_impl/platform_file.h" |
| 9 #include "webkit/plugins/ppapi/common.h" | 9 #include "webkit/plugins/ppapi/common.h" |
| 10 #include "webkit/plugins/ppapi/plugin_module.h" | 10 #include "webkit/plugins/ppapi/plugin_module.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 // The plugin owns the handle. | 35 // The plugin owns the handle. |
| 36 pipe_handle_ = PlatformFileToInt(base::kInvalidPlatformFileValue); | 36 pipe_handle_ = PlatformFileToInt(base::kInvalidPlatformFileValue); |
| 37 } | 37 } |
| 38 | 38 |
| 39 PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { | 39 PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { |
| 40 return this; | 40 return this; |
| 41 } | 41 } |
| 42 | 42 |
| 43 int32_t PPB_Broker_Impl::Connect(PP_CompletionCallback connect_callback) { | 43 int32_t PPB_Broker_Impl::Connect( |
| 44 if (!connect_callback.func) { | 44 scoped_refptr<TrackedCallback> connect_callback) { |
| 45 // Synchronous calls are not supported. | |
| 46 return PP_ERROR_BLOCKS_MAIN_THREAD; | |
| 47 } | |
| 48 | |
| 49 // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process. | 45 // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process. |
| 50 | 46 |
| 51 if (broker_) { | 47 if (broker_) { |
| 52 // May only be called once. | 48 // May only be called once. |
| 53 return PP_ERROR_FAILED; | 49 return PP_ERROR_FAILED; |
| 54 } | 50 } |
| 55 | 51 |
| 56 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 52 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 57 if (!plugin_instance) | 53 if (!plugin_instance) |
| 58 return PP_ERROR_FAILED; | 54 return PP_ERROR_FAILED; |
| 59 | 55 |
| 60 // The callback must be populated now in case we are connected to the broker | 56 // The callback must be populated now in case we are connected to the broker |
| 61 // and BrokerConnected is called before ConnectToBroker returns. | 57 // and BrokerConnected is called before ConnectToBroker returns. |
| 62 // Because it must be created now, it must be aborted and cleared if | 58 // Because it must be created now, it must be aborted and cleared if |
| 63 // ConnectToBroker fails. | 59 // ConnectToBroker fails. |
| 64 connect_callback_ = new TrackedCallback(this, connect_callback); | 60 connect_callback_ = connect_callback; |
| 65 | 61 |
| 66 broker_ = plugin_instance->delegate()->ConnectToBroker(this); | 62 broker_ = plugin_instance->delegate()->ConnectToBroker(this); |
| 67 if (!broker_) { | 63 if (!broker_) { |
| 68 TrackedCallback::ClearAndAbort(&connect_callback_); | 64 TrackedCallback::ClearAndAbort(&connect_callback_); |
| 69 return PP_ERROR_FAILED; | 65 return PP_ERROR_FAILED; |
| 70 } | 66 } |
| 71 | 67 |
| 72 return PP_OK_COMPLETIONPENDING; | 68 return PP_OK_COMPLETIONPENDING; |
| 73 } | 69 } |
| 74 | 70 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 89 pipe_handle_ = handle; | 85 pipe_handle_ = handle; |
| 90 | 86 |
| 91 // Synchronous calls are not supported. | 87 // Synchronous calls are not supported. |
| 92 DCHECK(TrackedCallback::IsPending(connect_callback_)); | 88 DCHECK(TrackedCallback::IsPending(connect_callback_)); |
| 93 | 89 |
| 94 TrackedCallback::ClearAndRun(&connect_callback_, result); | 90 TrackedCallback::ClearAndRun(&connect_callback_, result); |
| 95 } | 91 } |
| 96 | 92 |
| 97 } // namespace ppapi | 93 } // namespace ppapi |
| 98 } // namespace webkit | 94 } // namespace webkit |
| OLD | NEW |