OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/guest_view/renderer/guest_view_container.h" | 5 #include "components/guest_view/renderer/guest_view_container.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "components/guest_view/common/guest_view_constants.h" | 8 #include "components/guest_view/common/guest_view_constants.h" |
9 #include "components/guest_view/common/guest_view_messages.h" | 9 #include "components/guest_view/common/guest_view_messages.h" |
10 #include "components/guest_view/renderer/guest_view_request.h" | 10 #include "components/guest_view/renderer/guest_view_request.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 RunDestructionCallback(embedder_frame_destroyed); | 93 RunDestructionCallback(embedder_frame_destroyed); |
94 | 94 |
95 // Invalidate weak references to us to avoid late arriving tasks from running | 95 // Invalidate weak references to us to avoid late arriving tasks from running |
96 // during destruction | 96 // during destruction |
97 weak_ptr_factory_.InvalidateWeakPtrs(); | 97 weak_ptr_factory_.InvalidateWeakPtrs(); |
98 | 98 |
99 if (element_instance_id() != guest_view::kInstanceIDNone) | 99 if (element_instance_id() != guest_view::kInstanceIDNone) |
100 g_guest_view_container_map.Get().erase(element_instance_id()); | 100 g_guest_view_container_map.Get().erase(element_instance_id()); |
101 | 101 |
102 if (pending_response_.get()) | 102 if (pending_response_.get()) |
103 pending_response_->ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | 103 pending_response_->HandleDefaultResponse(); |
104 | 104 |
105 while (pending_requests_.size() > 0) { | 105 while (pending_requests_.size() > 0) { |
106 linked_ptr<GuestViewRequest> pending_request = pending_requests_.front(); | 106 linked_ptr<GuestViewRequest> pending_request = pending_requests_.front(); |
107 pending_requests_.pop_front(); | 107 pending_requests_.pop_front(); |
108 // Call the JavaScript callbacks with no arguments which implies an error. | 108 pending_request->HandleDefaultResponse(); |
109 pending_request->ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | |
110 } | 109 } |
111 | 110 |
112 delete this; | 111 delete this; |
113 } | 112 } |
114 | 113 |
115 void GuestViewContainer::RegisterDestructionCallback( | 114 void GuestViewContainer::RegisterDestructionCallback( |
116 v8::Local<v8::Function> callback, | 115 v8::Local<v8::Function> callback, |
117 v8::Isolate* isolate) { | 116 v8::Isolate* isolate) { |
118 destruction_callback_.Reset(isolate, callback); | 117 destruction_callback_.Reset(isolate, callback); |
119 destruction_isolate_ = isolate; | 118 destruction_isolate_ = isolate; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 213 |
215 void GuestViewContainer::DidDestroyElement() { | 214 void GuestViewContainer::DidDestroyElement() { |
216 Destroy(false); | 215 Destroy(false); |
217 } | 216 } |
218 | 217 |
219 base::WeakPtr<content::BrowserPluginDelegate> GuestViewContainer::GetWeakPtr() { | 218 base::WeakPtr<content::BrowserPluginDelegate> GuestViewContainer::GetWeakPtr() { |
220 return weak_ptr_factory_.GetWeakPtr(); | 219 return weak_ptr_factory_.GetWeakPtr(); |
221 } | 220 } |
222 | 221 |
223 } // namespace guest_view | 222 } // namespace guest_view |
OLD | NEW |