| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 using WebKit::WebCache; | 51 using WebKit::WebCache; |
| 52 using WebKit::WebCrossOriginPreflightResultCache; | 52 using WebKit::WebCrossOriginPreflightResultCache; |
| 53 using WebKit::WebFontCache; | 53 using WebKit::WebFontCache; |
| 54 using WebKit::WebRuntimeFeatures; | 54 using WebKit::WebRuntimeFeatures; |
| 55 using content::RenderThread; | 55 using content::RenderThread; |
| 56 | 56 |
| 57 namespace { | 57 namespace { |
| 58 | 58 |
| 59 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; | 59 static const int kCacheStatsDelayMS = 2000; |
| 60 | 60 |
| 61 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { | 61 class RendererResourceDelegate : public content::ResourceDispatcherDelegate { |
| 62 public: | 62 public: |
| 63 RendererResourceDelegate() | 63 RendererResourceDelegate() |
| 64 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 64 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( | 67 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( |
| 68 webkit_glue::ResourceLoaderBridge::Peer* current_peer, | 68 webkit_glue::ResourceLoaderBridge::Peer* current_peer, |
| 69 ResourceType::Type resource_type, | 69 ResourceType::Type resource_type, |
| 70 const net::URLRequestStatus& status) { | 70 const net::URLRequestStatus& status) { |
| 71 // Update the browser about our cache. | 71 // Update the browser about our cache. |
| 72 // Rate limit informing the host of our cache stats. | 72 // Rate limit informing the host of our cache stats. |
| 73 if (!weak_factory_.HasWeakPtrs()) { | 73 if (!weak_factory_.HasWeakPtrs()) { |
| 74 MessageLoop::current()->PostDelayedTask( | 74 MessageLoop::current()->PostDelayedTask( |
| 75 FROM_HERE, | 75 FROM_HERE, |
| 76 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, | 76 base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, |
| 77 weak_factory_.GetWeakPtr()), | 77 weak_factory_.GetWeakPtr()), |
| 78 kCacheStatsDelayMS); | 78 base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (status.status() != net::URLRequestStatus::CANCELED || | 81 if (status.status() != net::URLRequestStatus::CANCELED || |
| 82 status.error() == net::ERR_ABORTED) { | 82 status.error() == net::ERR_ABORTED) { |
| 83 return NULL; | 83 return NULL; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Resource canceled with a specific error are filtered. | 86 // Resource canceled with a specific error are filtered. |
| 87 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( | 87 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( |
| 88 resource_type, current_peer, status.error()); | 88 resource_type, current_peer, status.error()); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (clear_cache_pending_) { | 386 if (clear_cache_pending_) { |
| 387 clear_cache_pending_ = false; | 387 clear_cache_pending_ = false; |
| 388 WebCache::clear(); | 388 WebCache::clear(); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 const RendererContentSettingRules* | 392 const RendererContentSettingRules* |
| 393 ChromeRenderProcessObserver::content_setting_rules() const { | 393 ChromeRenderProcessObserver::content_setting_rules() const { |
| 394 return &content_setting_rules_; | 394 return &content_setting_rules_; |
| 395 } | 395 } |
| OLD | NEW |