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

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

Issue 8116009: Move RenderProcessObserver and RenderViewVisitor to content\public\renderer and put them in the c... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
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/chrome_content_renderer_client.h" 20 #include "chrome/renderer/chrome_content_renderer_client.h"
21 #include "chrome/renderer/content_settings_observer.h" 21 #include "chrome/renderer/content_settings_observer.h"
22 #include "chrome/renderer/security_filter_peer.h" 22 #include "chrome/renderer/security_filter_peer.h"
23 #include "content/common/resource_dispatcher.h" 23 #include "content/common/resource_dispatcher.h"
24 #include "content/common/resource_dispatcher_delegate.h" 24 #include "content/common/resource_dispatcher_delegate.h"
25 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
26 #include "content/public/renderer/render_view_visitor.h"
26 #include "content/renderer/render_thread.h" 27 #include "content/renderer/render_thread.h"
27 #include "content/renderer/render_view.h" 28 #include "content/renderer/render_view.h"
28 #include "content/renderer/render_view_visitor.h"
29 #include "crypto/nss_util.h" 29 #include "crypto/nss_util.h"
30 #include "media/base/media.h" 30 #include "media/base/media.h"
31 #include "media/base/media_switches.h" 31 #include "media/base/media_switches.h"
32 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
33 #include "net/base/net_module.h" 33 #include "net/base/net_module.h"
34 #include "third_party/sqlite/sqlite3.h" 34 #include "third_party/sqlite/sqlite3.h"
35 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" 35 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h"
36 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" 36 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCrossOriginPreflig htResultCache.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCrossOriginPreflig htResultCache.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 WebCache::getUsageStats(&stats); 105 WebCache::getUsageStats(&stats);
106 RenderThread::current()->Send(new ChromeViewHostMsg_UpdatedCacheStats( 106 RenderThread::current()->Send(new ChromeViewHostMsg_UpdatedCacheStats(
107 stats)); 107 stats));
108 } 108 }
109 109
110 ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_; 110 ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_;
111 111
112 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); 112 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
113 }; 113 };
114 114
115 class RenderViewContentSettingsSetter : public RenderViewVisitor { 115 class RenderViewContentSettingsSetter : public content::RenderViewVisitor {
116 public: 116 public:
117 RenderViewContentSettingsSetter(const GURL& url, 117 RenderViewContentSettingsSetter(const GURL& url,
118 const ContentSettings& content_settings) 118 const ContentSettings& content_settings)
119 : url_(url), 119 : url_(url),
120 content_settings_(content_settings) { 120 content_settings_(content_settings) {
121 } 121 }
122 122
123 virtual bool Visit(RenderView* render_view) { 123 virtual bool Visit(RenderView* render_view) {
124 if (GURL(render_view->webview()->mainFrame()->document().url()) == url_) { 124 if (GURL(render_view->webview()->mainFrame()->document().url()) == url_) {
125 ContentSettingsObserver::Get(render_view)->SetContentSettings( 125 ContentSettingsObserver::Get(render_view)->SetContentSettings(
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (on_navigation) { 459 if (on_navigation) {
460 clear_cache_pending_ = true; 460 clear_cache_pending_ = true;
461 } else { 461 } else {
462 WebCache::clear(); 462 WebCache::clear();
463 } 463 }
464 } 464 }
465 465
466 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { 466 void ChromeRenderProcessObserver::OnGetCacheResourceStats() {
467 WebCache::ResourceTypeStats stats; 467 WebCache::ResourceTypeStats stats;
468 WebCache::getResourceTypeStats(&stats); 468 WebCache::getResourceTypeStats(&stats);
469 Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); 469 RenderThread::current()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats));
470 } 470 }
471 471
472 #if defined(USE_TCMALLOC) 472 #if defined(USE_TCMALLOC)
473 void ChromeRenderProcessObserver::OnGetRendererTcmalloc() { 473 void ChromeRenderProcessObserver::OnGetRendererTcmalloc() {
474 std::string result; 474 std::string result;
475 char buffer[1024 * 32]; 475 char buffer[1024 * 32];
476 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); 476 MallocExtension::instance()->GetStats(buffer, sizeof(buffer));
477 result.append(buffer); 477 result.append(buffer);
478 Send(new ChromeViewHostMsg_RendererTcmalloc(result)); 478 RenderThread::current()->Send(new ChromeViewHostMsg_RendererTcmalloc(result));
479 } 479 }
480 480
481 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( 481 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling(
482 bool profiling, const std::string& filename_prefix) { 482 bool profiling, const std::string& filename_prefix) {
483 #if !defined(OS_WIN) 483 #if !defined(OS_WIN)
484 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. 484 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions.
485 if (profiling) 485 if (profiling)
486 HeapProfilerStart(filename_prefix.c_str()); 486 HeapProfilerStart(filename_prefix.c_str());
487 else 487 else
488 HeapProfilerStop(); 488 HeapProfilerStop();
489 #endif 489 #endif
490 } 490 }
491 491
492 void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile( 492 void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile(
493 const FilePath::StringType& filename) { 493 const FilePath::StringType& filename) {
494 #if !defined(OS_WIN) 494 #if !defined(OS_WIN)
495 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. 495 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions.
496 if (!IsHeapProfilerRunning()) 496 if (!IsHeapProfilerRunning())
497 return; 497 return;
498 char* profile = GetHeapProfile(); 498 char* profile = GetHeapProfile();
499 if (!profile) { 499 if (!profile) {
500 LOG(WARNING) << "Unable to get heap profile."; 500 LOG(WARNING) << "Unable to get heap profile.";
501 return; 501 return;
502 } 502 }
503 // The render process can not write to a file, so copy the result into 503 // The render process can not write to a file, so copy the result into
504 // a string and pass it to the handler (which runs on the browser host). 504 // a string and pass it to the handler (which runs on the browser host).
505 std::string result(profile); 505 std::string result(profile);
506 delete profile; 506 delete profile;
507 Send(new ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result)); 507 RenderThread::current()->Send(
508 new ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result));
508 #endif 509 #endif
509 } 510 }
510 511
511 #endif 512 #endif
512 513
513 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( 514 void ChromeRenderProcessObserver::OnSetFieldTrialGroup(
514 const std::string& field_trial_name, 515 const std::string& field_trial_name,
515 const std::string& group_name) { 516 const std::string& group_name) {
516 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); 517 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name);
517 } 518 }
518 519
519 void ChromeRenderProcessObserver::OnGetV8HeapStats() { 520 void ChromeRenderProcessObserver::OnGetV8HeapStats() {
520 v8::HeapStatistics heap_stats; 521 v8::HeapStatistics heap_stats;
521 v8::V8::GetHeapStatistics(&heap_stats); 522 v8::V8::GetHeapStatistics(&heap_stats);
522 Send(new ChromeViewHostMsg_V8HeapStats(heap_stats.total_heap_size(), 523 RenderThread::current()->Send(new ChromeViewHostMsg_V8HeapStats(
523 heap_stats.used_heap_size())); 524 heap_stats.total_heap_size(), heap_stats.used_heap_size()));
524 } 525 }
525 526
526 void ChromeRenderProcessObserver::OnPurgeMemory() { 527 void ChromeRenderProcessObserver::OnPurgeMemory() {
527 // Clear the object cache (as much as possible; some live objects cannot be 528 // Clear the object cache (as much as possible; some live objects cannot be
528 // freed). 529 // freed).
529 WebCache::clear(); 530 WebCache::clear();
530 531
531 // Clear the font/glyph cache. 532 // Clear the font/glyph cache.
532 WebFontCache::clear(); 533 WebFontCache::clear();
533 534
(...skipping 20 matching lines...) Expand all
554 if (client_) 555 if (client_)
555 client_->OnPurgeMemory(); 556 client_->OnPurgeMemory();
556 } 557 }
557 558
558 void ChromeRenderProcessObserver::ExecutePendingClearCache() { 559 void ChromeRenderProcessObserver::ExecutePendingClearCache() {
559 if (clear_cache_pending_) { 560 if (clear_cache_pending_) {
560 clear_cache_pending_ = false; 561 clear_cache_pending_ = false;
561 WebCache::clear(); 562 WebCache::clear();
562 } 563 }
563 } 564 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.h ('k') | chrome/renderer/extensions/extension_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698