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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 1232603002: This patch improves the way that GuestViewManager tracks the destruction of GuestView embedders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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 "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 using WebViewKey = std::pair<int, int>; 191 using WebViewKey = std::pair<int, int>;
192 using WebViewKeyToIDMap = std::map<WebViewKey, int>; 192 using WebViewKeyToIDMap = std::map<WebViewKey, int>;
193 static base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map = 193 static base::LazyInstance<WebViewKeyToIDMap> web_view_key_to_id_map =
194 LAZY_INSTANCE_INITIALIZER; 194 LAZY_INSTANCE_INITIALIZER;
195 195
196 } // namespace 196 } // namespace
197 197
198 // static 198 // static
199 void WebViewGuest::CleanUp(int embedder_process_id, int view_instance_id) { 199 void WebViewGuest::CleanUp(content::BrowserContext* browser_context,
200 GuestViewBase::CleanUp(embedder_process_id, view_instance_id); 200 int embedder_process_id,
201 201 int view_instance_id) {
202 auto rph = content::RenderProcessHost::FromID(embedder_process_id); 202 GuestViewBase::CleanUp(browser_context, embedder_process_id,
203 // TODO(paulmeyer): It should be impossible for rph to be nullptr here, but 203 view_instance_id);
204 // this check is needed here for now as there seems to be occasional crashes
205 // because of this (http//crbug.com/499438). This should be removed once the
206 // cause is discovered and fixed.
207 DCHECK(rph != nullptr)
208 << "Cannot find RenderProcessHost for embedder process ID# "
209 << embedder_process_id;
210 if (rph == nullptr)
211 return;
212 auto browser_context = rph->GetBrowserContext();
213 204
214 // Clean up rules registries for the WebView. 205 // Clean up rules registries for the WebView.
215 WebViewKey key(embedder_process_id, view_instance_id); 206 WebViewKey key(embedder_process_id, view_instance_id);
216 auto it = web_view_key_to_id_map.Get().find(key); 207 auto it = web_view_key_to_id_map.Get().find(key);
217 if (it != web_view_key_to_id_map.Get().end()) { 208 if (it != web_view_key_to_id_map.Get().end()) {
218 auto rules_registry_id = it->second; 209 auto rules_registry_id = it->second;
219 web_view_key_to_id_map.Get().erase(it); 210 web_view_key_to_id_map.Get().erase(it);
220 RulesRegistryService::Get(browser_context) 211 RulesRegistryService::Get(browser_context)
221 ->RemoveRulesRegistriesByID(rules_registry_id); 212 ->RemoveRulesRegistriesByID(rules_registry_id);
222 } 213 }
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 1448 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
1458 DispatchEventToView( 1449 DispatchEventToView(
1459 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); 1450 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass()));
1460 } 1451 }
1461 // Since we changed fullscreen state, sending a Resize message ensures that 1452 // Since we changed fullscreen state, sending a Resize message ensures that
1462 // renderer/ sees the change. 1453 // renderer/ sees the change.
1463 web_contents()->GetRenderViewHost()->WasResized(); 1454 web_contents()->GetRenderViewHost()->WasResized();
1464 } 1455 }
1465 1456
1466 } // namespace extensions 1457 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698