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

Side by Side Diff: chrome/renderer/chrome_render_process_observer.cc

Issue 7058041: Remove ResourceDispatcherHost dependency on Chrome's LoginHandler and ExternalProtocolHandler. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix deps Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.h ('k') | content/browser/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/native_library.h" 11 #include "base/native_library.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension_localization_peer.h" 17 #include "chrome/common/extensions/extension_localization_peer.h"
18 #include "chrome/common/net/net_resource_provider.h" 18 #include "chrome/common/net/net_resource_provider.h"
19 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
20 #include "chrome/renderer/content_settings_observer.h" 20 #include "chrome/renderer/content_settings_observer.h"
21 #include "chrome/renderer/security_filter_peer.h" 21 #include "chrome/renderer/security_filter_peer.h"
22 #include "content/common/resource_dispatcher.h" 22 #include "content/common/resource_dispatcher.h"
23 #include "content/common/resource_dispatcher_delegate.h"
23 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
24 #include "content/renderer/render_thread.h" 25 #include "content/renderer/render_thread.h"
25 #include "content/renderer/render_view.h" 26 #include "content/renderer/render_view.h"
26 #include "content/renderer/render_view_visitor.h" 27 #include "content/renderer/render_view_visitor.h"
27 #include "crypto/nss_util.h" 28 #include "crypto/nss_util.h"
28 #include "net/base/net_errors.h" 29 #include "net/base/net_errors.h"
29 #include "net/base/net_module.h" 30 #include "net/base/net_module.h"
30 #include "third_party/sqlite/sqlite3.h" 31 #include "third_party/sqlite/sqlite3.h"
31 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" 32 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
(...skipping 13 matching lines...) Expand all
46 #endif 47 #endif
47 48
48 using WebKit::WebCache; 49 using WebKit::WebCache;
49 using WebKit::WebCrossOriginPreflightResultCache; 50 using WebKit::WebCrossOriginPreflightResultCache;
50 using WebKit::WebFontCache; 51 using WebKit::WebFontCache;
51 52
52 namespace { 53 namespace {
53 54
54 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; 55 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
55 56
56 class RenderResourceObserver : public ResourceDispatcher::Observer { 57 class RendererResourceDelegate : public ResourceDispatcherDelegate {
57 public: 58 public:
58 RenderResourceObserver() 59 RendererResourceDelegate()
59 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 60 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
60 } 61 }
61 62
62 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( 63 virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete(
63 webkit_glue::ResourceLoaderBridge::Peer* current_peer, 64 webkit_glue::ResourceLoaderBridge::Peer* current_peer,
64 ResourceType::Type resource_type, 65 ResourceType::Type resource_type,
65 const net::URLRequestStatus& status) { 66 const net::URLRequestStatus& status) {
66 // Update the browser about our cache. 67 // Update the browser about our cache.
67 // Rate limit informing the host of our cache stats. 68 // Rate limit informing the host of our cache stats.
68 if (method_factory_.empty()) { 69 if (method_factory_.empty()) {
69 MessageLoop::current()->PostDelayedTask( 70 MessageLoop::current()->PostDelayedTask(
70 FROM_HERE, 71 FROM_HERE,
71 method_factory_.NewRunnableMethod( 72 method_factory_.NewRunnableMethod(
72 &RenderResourceObserver::InformHostOfCacheStats), 73 &RendererResourceDelegate::InformHostOfCacheStats),
73 kCacheStatsDelayMS); 74 kCacheStatsDelayMS);
74 } 75 }
75 76
76 if (status.status() != net::URLRequestStatus::CANCELED || 77 if (status.status() != net::URLRequestStatus::CANCELED ||
77 status.os_error() == net::ERR_ABORTED) { 78 status.os_error() == net::ERR_ABORTED) {
78 return NULL; 79 return NULL;
79 } 80 }
80 81
81 // Resource canceled with a specific error are filtered. 82 // Resource canceled with a specific error are filtered.
82 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( 83 return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest(
83 resource_type, current_peer, status.os_error()); 84 resource_type, current_peer, status.os_error());
84 } 85 }
85 86
86 virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( 87 virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse(
87 webkit_glue::ResourceLoaderBridge::Peer* current_peer, 88 webkit_glue::ResourceLoaderBridge::Peer* current_peer,
88 const std::string& mime_type, 89 const std::string& mime_type,
89 const GURL& url) { 90 const GURL& url) {
90 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( 91 return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
91 current_peer, RenderThread::current(), mime_type, url); 92 current_peer, RenderThread::current(), mime_type, url);
92 } 93 }
93 94
94 private: 95 private:
95 void InformHostOfCacheStats() { 96 void InformHostOfCacheStats() {
96 WebCache::UsageStats stats; 97 WebCache::UsageStats stats;
97 WebCache::getUsageStats(&stats); 98 WebCache::getUsageStats(&stats);
98 RenderThread::current()->Send(new ViewHostMsg_UpdatedCacheStats(stats)); 99 RenderThread::current()->Send(new ViewHostMsg_UpdatedCacheStats(stats));
99 } 100 }
100 101
101 ScopedRunnableMethodFactory<RenderResourceObserver> method_factory_; 102 ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_;
102 103
103 DISALLOW_COPY_AND_ASSIGN(RenderResourceObserver); 104 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
104 }; 105 };
105 106
106 class RenderViewContentSettingsSetter : public RenderViewVisitor { 107 class RenderViewContentSettingsSetter : public RenderViewVisitor {
107 public: 108 public:
108 RenderViewContentSettingsSetter(const GURL& url, 109 RenderViewContentSettingsSetter(const GURL& url,
109 const ContentSettings& content_settings) 110 const ContentSettings& content_settings)
110 : url_(url), 111 : url_(url),
111 content_settings_(content_settings) { 112 content_settings_(content_settings) {
112 } 113 }
113 114
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 304 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
304 if (command_line.HasSwitch(switches::kEnableWatchdog)) { 305 if (command_line.HasSwitch(switches::kEnableWatchdog)) {
305 // TODO(JAR): Need to implement renderer IO msgloop watchdog. 306 // TODO(JAR): Need to implement renderer IO msgloop watchdog.
306 } 307 }
307 308
308 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { 309 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) {
309 base::StatisticsRecorder::set_dump_on_exit(true); 310 base::StatisticsRecorder::set_dump_on_exit(true);
310 } 311 }
311 312
312 RenderThread* thread = RenderThread::current(); 313 RenderThread* thread = RenderThread::current();
313 thread->resource_dispatcher()->set_observer(new RenderResourceObserver()); 314 resource_delegate_.reset(new RendererResourceDelegate());
315 thread->resource_dispatcher()->set_delegate(resource_delegate_.get());
314 316
315 #if defined(OS_POSIX) 317 #if defined(OS_POSIX)
316 thread->AddFilter(new SuicideOnChannelErrorFilter()); 318 thread->AddFilter(new SuicideOnChannelErrorFilter());
317 #endif 319 #endif
318 320
319 #if defined(OS_MACOSX) 321 #if defined(OS_MACOSX)
320 // TODO(viettrungluu): Code taken from browser_main.cc. 322 // TODO(viettrungluu): Code taken from browser_main.cc.
321 int pipefd[2]; 323 int pipefd[2];
322 int ret = pipe(pipefd); 324 int ret = pipe(pipefd);
323 if (ret < 0) { 325 if (ret < 0) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // to free everything possible in just one pass. 480 // to free everything possible in just one pass.
479 while (!v8::V8::IdleNotification()) { 481 while (!v8::V8::IdleNotification()) {
480 } 482 }
481 483
482 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 484 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
483 // Tell tcmalloc to release any free pages it's still holding. 485 // Tell tcmalloc to release any free pages it's still holding.
484 MallocExtension::instance()->ReleaseFreeMemory(); 486 MallocExtension::instance()->ReleaseFreeMemory();
485 #endif 487 #endif
486 } 488 }
487 489
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.h ('k') | content/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698