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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 if (broker_) { | 63 if (broker_) { |
64 // May only be called once. | 64 // May only be called once. |
65 return PP_ERROR_FAILED; | 65 return PP_ERROR_FAILED; |
66 } | 66 } |
67 | 67 |
68 // The callback must be populated now in case we are connected to the broker | 68 // The callback must be populated now in case we are connected to the broker |
69 // and BrokerConnected is called before ConnectToPpapiBroker returns. | 69 // and BrokerConnected is called before ConnectToPpapiBroker returns. |
70 // Because it must be created now, it must be aborted and cleared if | 70 // Because it must be created now, it must be aborted and cleared if |
71 // ConnectToPpapiBroker fails. | 71 // ConnectToPpapiBroker fails. |
72 PP_Resource resource_id = GetReferenceNoAddRef(); | |
73 CHECK(resource_id); | |
74 connect_callback_ = new TrackedCompletionCallback( | 72 connect_callback_ = new TrackedCompletionCallback( |
75 instance()->module()->GetCallbackTracker(), resource_id, | 73 instance()->module()->GetCallbackTracker(), pp_resource(), |
76 connect_callback); | 74 connect_callback); |
77 | 75 |
78 broker_ = instance()->delegate()->ConnectToPpapiBroker(this); | 76 broker_ = instance()->delegate()->ConnectToPpapiBroker(this); |
79 if (!broker_) { | 77 if (!broker_) { |
80 scoped_refptr<TrackedCompletionCallback> callback; | 78 scoped_refptr<TrackedCompletionCallback> callback; |
81 callback.swap(connect_callback_); | 79 callback.swap(connect_callback_); |
82 callback->Abort(); | 80 callback->Abort(); |
83 return PP_ERROR_FAILED; | 81 return PP_ERROR_FAILED; |
84 } | 82 } |
85 | 83 |
(...skipping 19 matching lines...) Expand all Loading... |
105 // Synchronous calls are not supported. | 103 // Synchronous calls are not supported. |
106 DCHECK(connect_callback_.get() && !connect_callback_->completed()); | 104 DCHECK(connect_callback_.get() && !connect_callback_->completed()); |
107 | 105 |
108 scoped_refptr<TrackedCompletionCallback> callback; | 106 scoped_refptr<TrackedCompletionCallback> callback; |
109 callback.swap(connect_callback_); | 107 callback.swap(connect_callback_); |
110 callback->Run(result); // Will complete abortively if necessary. | 108 callback->Run(result); // Will complete abortively if necessary. |
111 } | 109 } |
112 | 110 |
113 } // namespace ppapi | 111 } // namespace ppapi |
114 } // namespace webkit | 112 } // namespace webkit |
OLD | NEW |