| 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 "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 "webkit/plugins/ppapi/common.h" | 8 #include "webkit/plugins/ppapi/common.h" | 
| 9 #include "webkit/plugins/ppapi/plugin_module.h" | 9 #include "webkit/plugins/ppapi/plugin_module.h" | 
| 10 | 10 | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 60 }; | 60 }; | 
| 61 | 61 | 
| 62 }  // namespace | 62 }  // namespace | 
| 63 | 63 | 
| 64 // PPB_Broker_Impl ------------------------------------------------------ | 64 // PPB_Broker_Impl ------------------------------------------------------ | 
| 65 | 65 | 
| 66 PPB_Broker_Impl::PPB_Broker_Impl(PluginInstance* instance) | 66 PPB_Broker_Impl::PPB_Broker_Impl(PluginInstance* instance) | 
| 67     : Resource(instance), | 67     : Resource(instance), | 
| 68       broker_(NULL), | 68       broker_(NULL), | 
| 69       connect_callback_(), | 69       connect_callback_(), | 
| 70       pipe_handle_(0) { | 70       pipe_handle_(base::kInvalidPlatformFileValue) { | 
| 71 } | 71 } | 
| 72 | 72 | 
| 73 PPB_Broker_Impl::~PPB_Broker_Impl() { | 73 PPB_Broker_Impl::~PPB_Broker_Impl() { | 
| 74   if (broker_) { | 74   if (broker_) { | 
| 75     broker_->Release(instance()); | 75     broker_->Release(instance()); | 
| 76     broker_ = NULL; | 76     broker_ = NULL; | 
| 77   } | 77   } | 
| 78 | 78 | 
| 79   // TODO(ddorwin): Should the plugin or Chrome free the handle? | 79   // The plugin owns the handle. | 
| 80   pipe_handle_ = 0; | 80   pipe_handle_ = base::kInvalidPlatformFileValue; | 
| 81 } | 81 } | 
| 82 | 82 | 
| 83 const PPB_BrokerTrusted* PPB_Broker_Impl::GetTrustedInterface() { | 83 const PPB_BrokerTrusted* PPB_Broker_Impl::GetTrustedInterface() { | 
| 84   return &ppb_brokertrusted; | 84   return &ppb_brokertrusted; | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 int32_t PPB_Broker_Impl::Connect( | 87 int32_t PPB_Broker_Impl::Connect( | 
| 88     PluginDelegate* plugin_delegate, | 88     PluginDelegate* plugin_delegate, | 
| 89     PP_CompletionCallback connect_callback) { | 89     PP_CompletionCallback connect_callback) { | 
| 90   // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process. | 90   // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process. | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 101   PP_Resource resource_id = GetReferenceNoAddRef(); | 101   PP_Resource resource_id = GetReferenceNoAddRef(); | 
| 102   CHECK(resource_id); | 102   CHECK(resource_id); | 
| 103   connect_callback_ = new TrackedCompletionCallback( | 103   connect_callback_ = new TrackedCompletionCallback( | 
| 104       instance()->module()->GetCallbackTracker(), resource_id, | 104       instance()->module()->GetCallbackTracker(), resource_id, | 
| 105       connect_callback); | 105       connect_callback); | 
| 106   return PP_ERROR_WOULDBLOCK; | 106   return PP_ERROR_WOULDBLOCK; | 
| 107 } | 107 } | 
| 108 | 108 | 
| 109 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { | 109 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { | 
| 110   *handle = pipe_handle_; | 110   *handle = pipe_handle_; | 
| 111 |  | 
| 112   if (!*handle) |  | 
| 113     return PP_ERROR_FAILED; |  | 
| 114 |  | 
| 115   return PP_OK; | 111   return PP_OK; | 
| 116 } | 112 } | 
| 117 | 113 | 
| 118 PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() { | 114 PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() { | 
| 119   return this; | 115   return this; | 
| 120 } | 116 } | 
| 121 | 117 | 
|  | 118 // Transfers ownership of the handle to the plugin. | 
| 122 void PPB_Broker_Impl::BrokerConnected(int32_t handle) { | 119 void PPB_Broker_Impl::BrokerConnected(int32_t handle) { | 
| 123   DCHECK(handle); | 120   DCHECK(handle); | 
| 124   pipe_handle_ = handle; | 121   pipe_handle_ = handle; | 
| 125 | 122 | 
| 126   // Synchronous calls are not supported. | 123   // Synchronous calls are not supported. | 
| 127   DCHECK(connect_callback_.get() && !connect_callback_->completed()); | 124   DCHECK(connect_callback_.get() && !connect_callback_->completed()); | 
| 128 | 125 | 
| 129   scoped_refptr<TrackedCompletionCallback> callback; | 126   scoped_refptr<TrackedCompletionCallback> callback; | 
| 130   callback.swap(connect_callback_); | 127   callback.swap(connect_callback_); | 
| 131   callback->Run(0);  // Will complete abortively if necessary. | 128   callback->Run(PP_OK);  // Will complete abortively if necessary. | 
| 132 } | 129 } | 
| 133 | 130 | 
| 134 }  // namespace ppapi | 131 }  // namespace ppapi | 
| 135 }  // namespace webkit | 132 }  // namespace webkit | 
| OLD | NEW | 
|---|