| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 namespace { | 60 namespace { |
| 61 | 61 |
| 62 const int kCacheStatsDelayMS = 2000; | 62 const int kCacheStatsDelayMS = 2000; |
| 63 | 63 |
| 64 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { | 64 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { |
| 65 public: | 65 public: |
| 66 RendererResourceDelegate() | 66 RendererResourceDelegate() |
| 67 : weak_factory_(this) { | 67 : weak_factory_(this) { |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual content::RequestPeer* OnRequestComplete( | 70 content::RequestPeer* OnRequestComplete(content::RequestPeer* current_peer, |
| 71 content::RequestPeer* current_peer, | 71 content::ResourceType resource_type, |
| 72 content::ResourceType resource_type, | 72 int error_code) override { |
| 73 int error_code) override { | |
| 74 // Update the browser about our cache. | 73 // Update the browser about our cache. |
| 75 // Rate limit informing the host of our cache stats. | 74 // Rate limit informing the host of our cache stats. |
| 76 if (!weak_factory_.HasWeakPtrs()) { | 75 if (!weak_factory_.HasWeakPtrs()) { |
| 77 base::MessageLoop::current()->PostDelayedTask( | 76 base::MessageLoop::current()->PostDelayedTask( |
| 78 FROM_HERE, | 77 FROM_HERE, |
| 79 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, | 78 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, |
| 80 weak_factory_.GetWeakPtr()), | 79 weak_factory_.GetWeakPtr()), |
| 81 base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); | 80 base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); |
| 82 } | 81 } |
| 83 | 82 |
| 84 if (error_code == net::ERR_ABORTED) { | 83 if (error_code == net::ERR_ABORTED) { |
| 85 return NULL; | 84 return NULL; |
| 86 } | 85 } |
| 87 | 86 |
| 88 // Resource canceled with a specific error are filtered. | 87 // Resource canceled with a specific error are filtered. |
| 89 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( | 88 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( |
| 90 resource_type, current_peer, error_code); | 89 resource_type, current_peer, error_code); |
| 91 } | 90 } |
| 92 | 91 |
| 93 virtual content::RequestPeer* OnReceivedResponse( | 92 content::RequestPeer* OnReceivedResponse(content::RequestPeer* current_peer, |
| 94 content::RequestPeer* current_peer, | 93 const std::string& mime_type, |
| 95 const std::string& mime_type, | 94 const GURL& url) override { |
| 96 const GURL& url) override { | |
| 97 #if defined(ENABLE_EXTENSIONS) | 95 #if defined(ENABLE_EXTENSIONS) |
| 98 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( | 96 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( |
| 99 current_peer, RenderThread::Get(), mime_type, url); | 97 current_peer, RenderThread::Get(), mime_type, url); |
| 100 #else | 98 #else |
| 101 return NULL; | 99 return NULL; |
| 102 #endif | 100 #endif |
| 103 } | 101 } |
| 104 | 102 |
| 105 private: | 103 private: |
| 106 void InformHostOfCacheStats() { | 104 void InformHostOfCacheStats() { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 372 } |
| 375 | 373 |
| 376 void ChromeRenderProcessObserver::OnGetV8HeapStats() { | 374 void ChromeRenderProcessObserver::OnGetV8HeapStats() { |
| 377 HeapStatisticsCollector::Instance()->InitiateCollection(); | 375 HeapStatisticsCollector::Instance()->InitiateCollection(); |
| 378 } | 376 } |
| 379 | 377 |
| 380 const RendererContentSettingRules* | 378 const RendererContentSettingRules* |
| 381 ChromeRenderProcessObserver::content_setting_rules() const { | 379 ChromeRenderProcessObserver::content_setting_rules() const { |
| 382 return &content_setting_rules_; | 380 return &content_setting_rules_; |
| 383 } | 381 } |
| OLD | NEW |