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