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

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

Issue 1056793002: Move clear cache code from chrome/ (ChromeWVGDelegate) to extensions/ (WVGuest) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-spbdr
Patch Set: fix test on windows Created 5 years, 8 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"
11 #include "components/web_cache/browser/web_cache_manager.h"
10 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/child_process_security_policy.h" 14 #include "content/public/browser/child_process_security_policy.h"
13 #include "content/public/browser/native_web_keyboard_event.h" 15 #include "content/public/browser/native_web_keyboard_event.h"
14 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/notification_types.h" 20 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData")); 700 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData"));
699 content::StoragePartition* partition = 701 content::StoragePartition* partition =
700 content::BrowserContext::GetStoragePartition( 702 content::BrowserContext::GetStoragePartition(
701 web_contents()->GetBrowserContext(), 703 web_contents()->GetBrowserContext(),
702 web_contents()->GetSiteInstance()); 704 web_contents()->GetSiteInstance());
703 705
704 if (!partition) 706 if (!partition)
705 return false; 707 return false;
706 708
707 if (removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE) { 709 if (removal_mask & webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE) {
708 if (web_view_guest_delegate_) { 710 // First clear http cache data and then clear the rest in
709 // First clear http cache data and then clear the rest in 711 // |ClearDataInternal|.
710 // |ClearDataInternal|. 712 int render_process_id = web_contents()->GetRenderProcessHost()->GetID();
711 web_view_guest_delegate_->ClearCache( 713 // We need to clear renderer cache separately for our process because
712 remove_since, base::Bind(&WebViewGuest::ClearDataInternal, 714 // StoragePartitionHttpCacheDataRemover::ClearData() does not clear that.
713 weak_ptr_factory_.GetWeakPtr(), remove_since, 715 web_cache::WebCacheManager::GetInstance()->Remove(render_process_id);
714 removal_mask, callback)); 716 web_cache::WebCacheManager::GetInstance()->ClearCacheForProcess(
715 return true; 717 render_process_id);
716 } 718
719 base::Closure cache_removal_done_callback = base::Bind(
720 &WebViewGuest::ClearDataInternal, weak_ptr_factory_.GetWeakPtr(),
721 remove_since, removal_mask, callback);
722 // StoragePartitionHttpCacheDataRemover removes itself when it is done.
723 // components/, move |ClearCache| to WebViewGuest: http//crbug.com/471287.
724 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange(
725 partition, remove_since, base::Time::Now())
726 ->Remove(cache_removal_done_callback);
727
728 return true;
Fady Samuel 2015/04/26 15:06:07 I just noticed this early exit. What happens if yo
lazyboy 2015/04/26 15:16:51 ClearDataInternal above in |cache_removal_done_cal
717 } 729 }
718 730
719 ClearDataInternal(remove_since, removal_mask, callback); 731 ClearDataInternal(remove_since, removal_mask, callback);
720 return true; 732 return true;
721 } 733 }
722 734
723 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents) 735 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents)
724 : GuestView<WebViewGuest>(owner_web_contents), 736 : GuestView<WebViewGuest>(owner_web_contents),
725 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), 737 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID),
726 find_helper_(this), 738 find_helper_(this),
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 1425 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
1414 DispatchEventToView( 1426 DispatchEventToView(
1415 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); 1427 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass()));
1416 } 1428 }
1417 // Since we changed fullscreen state, sending a Resize message ensures that 1429 // Since we changed fullscreen state, sending a Resize message ensures that
1418 // renderer/ sees the change. 1430 // renderer/ sees the change.
1419 web_contents()->GetRenderViewHost()->WasResized(); 1431 web_contents()->GetRenderViewHost()->WasResized();
1420 } 1432 }
1421 1433
1422 } // namespace extensions 1434 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/BUILD.gn ('k') | extensions/browser/guest_view/web_view/web_view_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698