Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: components/guest_view/renderer/guest_view_container.cc

Issue 1769273004: Remove V8RecrusionScope, cleanup call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/base/v8_unit_test.cc ('k') | components/guest_view/renderer/guest_view_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/renderer/render_frame.h" 11 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
14 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
15 14
16 namespace { 15 namespace {
17 16
18 using GuestViewContainerMap = std::map<int, guest_view::GuestViewContainer*>; 17 using GuestViewContainerMap = std::map<int, guest_view::GuestViewContainer*>;
19 static base::LazyInstance<GuestViewContainerMap> g_guest_view_container_map = 18 static base::LazyInstance<GuestViewContainerMap> g_guest_view_container_map =
20 LAZY_INSTANCE_INITIALIZER; 19 LAZY_INSTANCE_INITIALIZER;
21 20
22 } // namespace 21 } // namespace
23 22
24 namespace guest_view { 23 namespace guest_view {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void GuestViewContainer::HandlePendingResponseCallback( 146 void GuestViewContainer::HandlePendingResponseCallback(
148 const IPC::Message& message) { 147 const IPC::Message& message) {
149 CHECK(pending_response_.get()); 148 CHECK(pending_response_.get());
150 linked_ptr<GuestViewRequest> pending_response(pending_response_.release()); 149 linked_ptr<GuestViewRequest> pending_response(pending_response_.release());
151 pending_response->HandleResponse(message); 150 pending_response->HandleResponse(message);
152 } 151 }
153 152
154 void GuestViewContainer::RunDestructionCallback(bool embedder_frame_destroyed) { 153 void GuestViewContainer::RunDestructionCallback(bool embedder_frame_destroyed) {
155 // Do not attempt to run |destruction_callback_| if the embedder frame was 154 // Do not attempt to run |destruction_callback_| if the embedder frame was
156 // destroyed. Trying to invoke callback on RenderFrame destruction results in 155 // destroyed. Trying to invoke callback on RenderFrame destruction results in
157 // assertion failure when calling WebScopedMicrotaskSuppression. 156 // assertion failure when calling v8::MicrotasksScope.
158 if (embedder_frame_destroyed) 157 if (embedder_frame_destroyed)
159 return; 158 return;
160 159
161 // Call the destruction callback, if one is registered. 160 // Call the destruction callback, if one is registered.
162 if (!destruction_callback_.IsEmpty()) { 161 if (!destruction_callback_.IsEmpty()) {
163 v8::HandleScope handle_scope(destruction_isolate_); 162 v8::HandleScope handle_scope(destruction_isolate_);
164 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New( 163 v8::Local<v8::Function> callback = v8::Local<v8::Function>::New(
165 destruction_isolate_, destruction_callback_); 164 destruction_isolate_, destruction_callback_);
166 v8::Local<v8::Context> context = callback->CreationContext(); 165 v8::Local<v8::Context> context = callback->CreationContext();
167 if (context.IsEmpty()) 166 if (context.IsEmpty())
168 return; 167 return;
169 168
170 v8::Context::Scope context_scope(context); 169 v8::Context::Scope context_scope(context);
171 blink::WebScopedMicrotaskSuppression suppression; 170 v8::MicrotasksScope microtasks(
171 destruction_isolate_, v8::MicrotasksScope::kDoNotRunMicrotasks);
172 172
173 callback->Call(context->Global(), 0 /* argc */, nullptr); 173 callback->Call(context->Global(), 0 /* argc */, nullptr);
174 } 174 }
175 } 175 }
176 176
177 void GuestViewContainer::OnHandleCallback(const IPC::Message& message) { 177 void GuestViewContainer::OnHandleCallback(const IPC::Message& message) {
178 // Handle the callback for the current request with a pending response. 178 // Handle the callback for the current request with a pending response.
179 HandlePendingResponseCallback(message); 179 HandlePendingResponseCallback(message);
180 // Perform the subsequent request if one exists. 180 // Perform the subsequent request if one exists.
181 PerformPendingRequest(); 181 PerformPendingRequest();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void GuestViewContainer::DidDestroyElement() { 215 void GuestViewContainer::DidDestroyElement() {
216 Destroy(false); 216 Destroy(false);
217 } 217 }
218 218
219 base::WeakPtr<content::BrowserPluginDelegate> GuestViewContainer::GetWeakPtr() { 219 base::WeakPtr<content::BrowserPluginDelegate> GuestViewContainer::GetWeakPtr() {
220 return weak_ptr_factory_.GetWeakPtr(); 220 return weak_ptr_factory_.GetWeakPtr();
221 } 221 }
222 222
223 } // namespace guest_view 223 } // namespace guest_view
OLDNEW
« no previous file with comments | « chrome/test/base/v8_unit_test.cc ('k') | components/guest_view/renderer/guest_view_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698