OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/chrome_render_process_observer.h" | 5 #include "chrome/renderer/chrome_render_process_observer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/allocator/allocator_extension.h" | 10 #include "base/allocator/allocator_extension.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { | 69 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { |
70 public: | 70 public: |
71 RendererResourceDelegate() | 71 RendererResourceDelegate() |
72 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 72 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
73 } | 73 } |
74 | 74 |
75 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( | 75 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( |
76 webkit_glue::ResourceLoaderBridge::Peer* current_peer, | 76 webkit_glue::ResourceLoaderBridge::Peer* current_peer, |
77 ResourceType::Type resource_type, | 77 ResourceType::Type resource_type, |
78 int error_code) { | 78 int error_code) OVERRIDE { |
79 // Update the browser about our cache. | 79 // Update the browser about our cache. |
80 // Rate limit informing the host of our cache stats. | 80 // Rate limit informing the host of our cache stats. |
81 if (!weak_factory_.HasWeakPtrs()) { | 81 if (!weak_factory_.HasWeakPtrs()) { |
82 MessageLoop::current()->PostDelayedTask( | 82 MessageLoop::current()->PostDelayedTask( |
83 FROM_HERE, | 83 FROM_HERE, |
84 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, | 84 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, |
85 weak_factory_.GetWeakPtr()), | 85 weak_factory_.GetWeakPtr()), |
86 base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); | 86 base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); |
87 } | 87 } |
88 | 88 |
89 if (error_code == net::ERR_ABORTED) { | 89 if (error_code == net::ERR_ABORTED) { |
90 return NULL; | 90 return NULL; |
91 } | 91 } |
92 | 92 |
93 // Resource canceled with a specific error are filtered. | 93 // Resource canceled with a specific error are filtered. |
94 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( | 94 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( |
95 resource_type, current_peer, error_code); | 95 resource_type, current_peer, error_code); |
96 } | 96 } |
97 | 97 |
98 virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( | 98 virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( |
99 webkit_glue::ResourceLoaderBridge::Peer* current_peer, | 99 webkit_glue::ResourceLoaderBridge::Peer* current_peer, |
100 const std::string& mime_type, | 100 const std::string& mime_type, |
101 const GURL& url) { | 101 const GURL& url) OVERRIDE { |
102 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( | 102 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( |
103 current_peer, RenderThread::Get(), mime_type, url); | 103 current_peer, RenderThread::Get(), mime_type, url); |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 void InformHostOfCacheStats() { | 107 void InformHostOfCacheStats() { |
108 WebCache::UsageStats stats; | 108 WebCache::UsageStats stats; |
109 WebCache::getUsageStats(&stats); | 109 WebCache::getUsageStats(&stats); |
110 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); | 110 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); |
111 } | 111 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (clear_cache_pending_) { | 319 if (clear_cache_pending_) { |
320 clear_cache_pending_ = false; | 320 clear_cache_pending_ = false; |
321 WebCache::clear(); | 321 WebCache::clear(); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 const RendererContentSettingRules* | 325 const RendererContentSettingRules* |
326 ChromeRenderProcessObserver::content_setting_rules() const { | 326 ChromeRenderProcessObserver::content_setting_rules() const { |
327 return &content_setting_rules_; | 327 return &content_setting_rules_; |
328 } | 328 } |
OLD | NEW |