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

Side by Side Diff: content/renderer/render_thread.cc

Issue 7222023: Forward handling of low-mem message to the content renderer client. Add APIs to handle this case. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix constructor Created 9 years, 5 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 "content/renderer/render_thread.h" 5 #include "content/renderer/render_thread.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/metrics/stats_table.h" 18 #include "base/metrics/stats_table.h"
19 #include "base/process_util.h" 19 #include "base/process_util.h"
20 #include "base/shared_memory.h" 20 #include "base/shared_memory.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/threading/thread_local.h" 22 #include "base/threading/thread_local.h"
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "chrome/common/render_messages.h"
jam 2011/07/21 16:35:27 also, code in content can't include code in chrome
Greg Billock 2011/07/21 19:10:01 Is there a lint or presubmit to run that detects t
jam 2011/07/22 16:31:50 there's tools\checkdeps\checkdeps.py. We don't run
Greg Billock 2011/07/22 17:02:07 cool. I did see the check_deps fail on the trybots
24 #include "content/common/appcache/appcache_dispatcher.h" 25 #include "content/common/appcache/appcache_dispatcher.h"
26 #include "content/common/content_notification_types.h"
25 #include "content/common/content_switches.h" 27 #include "content/common/content_switches.h"
26 #include "content/common/database_messages.h" 28 #include "content/common/database_messages.h"
27 #include "content/common/db_message_filter.h" 29 #include "content/common/db_message_filter.h"
28 #include "content/common/dom_storage_messages.h" 30 #include "content/common/dom_storage_messages.h"
29 #include "content/common/gpu/gpu_messages.h" 31 #include "content/common/gpu/gpu_messages.h"
32 #include "content/common/notification_service.h"
33 #include "content/common/notification_source.h"
30 #include "content/common/plugin_messages.h" 34 #include "content/common/plugin_messages.h"
31 #include "content/common/renderer_preferences.h" 35 #include "content/common/renderer_preferences.h"
32 #include "content/common/resource_messages.h" 36 #include "content/common/resource_messages.h"
33 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
34 #include "content/common/web_database_observer_impl.h" 38 #include "content/common/web_database_observer_impl.h"
35 #include "content/plugin/npobject_util.h" 39 #include "content/plugin/npobject_util.h"
36 #include "content/renderer/content_renderer_client.h" 40 #include "content/renderer/content_renderer_client.h"
37 #include "content/renderer/gpu/gpu_channel_host.h" 41 #include "content/renderer/gpu/gpu_channel_host.h"
38 #include "content/renderer/indexed_db_dispatcher.h" 42 #include "content/renderer/indexed_db_dispatcher.h"
39 #include "content/renderer/media/audio_input_message_filter.h" 43 #include "content/renderer/media/audio_input_message_filter.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 408
405 bool handled = true; 409 bool handled = true;
406 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) 410 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg)
407 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, 411 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL,
408 OnSetZoomLevelForCurrentURL) 412 OnSetZoomLevelForCurrentURL)
409 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) 413 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
410 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) 414 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors)
411 // TODO(port): removed from render_messages_internal.h; 415 // TODO(port): removed from render_messages_internal.h;
412 // is there a new non-windows message I should add here? 416 // is there a new non-windows message I should add here?
413 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) 417 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
418 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
414 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) 419 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
415 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) 420 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged)
416 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) 421 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent)
417 IPC_MESSAGE_UNHANDLED(handled = false) 422 IPC_MESSAGE_UNHANDLED(handled = false)
418 IPC_END_MESSAGE_MAP() 423 IPC_END_MESSAGE_MAP()
419 return handled; 424 return handled;
420 } 425 }
421 426
422 void RenderThread::OnSetNextPageID(int32 next_page_id) { 427 void RenderThread::OnSetNextPageID(int32 next_page_id) {
423 // This should only be called at process initialization time, so we shouldn't 428 // This should only be called at process initialization time, so we shouldn't
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 675 }
671 676
672 void RenderThread::ScheduleIdleHandler(double initial_delay_s) { 677 void RenderThread::ScheduleIdleHandler(double initial_delay_s) {
673 idle_notification_delay_in_s_ = initial_delay_s; 678 idle_notification_delay_in_s_ = initial_delay_s;
674 idle_timer_.Stop(); 679 idle_timer_.Stop();
675 idle_timer_.Start( 680 idle_timer_.Start(
676 base::TimeDelta::FromSeconds(static_cast<int64>(initial_delay_s)), 681 base::TimeDelta::FromSeconds(static_cast<int64>(initial_delay_s)),
677 this, &RenderThread::IdleHandler); 682 this, &RenderThread::IdleHandler);
678 } 683 }
679 684
685 void RenderThread::OnPurgeMemory() {
686 NotificationService::current()->Notify(
687 content::NOTIFICATION_PURGE_MEMORY,
688 Source<void>(NULL),
689 NotificationService::NoDetails());
690 }
691
680 void RenderThread::OnPurgePluginListCache(bool reload_pages) { 692 void RenderThread::OnPurgePluginListCache(bool reload_pages) {
681 EnsureWebKitInitialized(); 693 EnsureWebKitInitialized();
682 // The call below will cause a GetPlugins call with refresh=true, but at this 694 // The call below will cause a GetPlugins call with refresh=true, but at this
683 // point we already know that the browser has refreshed its list, so disable 695 // point we already know that the browser has refreshed its list, so disable
684 // refresh temporarily to prevent each renderer process causing the list to be 696 // refresh temporarily to prevent each renderer process causing the list to be
685 // regenerated. 697 // regenerated.
686 plugin_refresh_allowed_ = false; 698 plugin_refresh_allowed_ = false;
687 WebKit::resetPluginCache(reload_pages); 699 WebKit::resetPluginCache(reload_pages);
688 plugin_refresh_allowed_ = true; 700 plugin_refresh_allowed_ = true;
689 } 701 }
(...skipping 15 matching lines...) Expand all
705 717
706 void RenderThread::RegisterExtension(v8::Extension* extension) { 718 void RenderThread::RegisterExtension(v8::Extension* extension) {
707 WebScriptController::registerExtension(extension); 719 WebScriptController::registerExtension(extension);
708 v8_extensions_.insert(extension->name()); 720 v8_extensions_.insert(extension->name());
709 } 721 }
710 722
711 bool RenderThread::IsRegisteredExtension( 723 bool RenderThread::IsRegisteredExtension(
712 const std::string& v8_extension_name) const { 724 const std::string& v8_extension_name) const {
713 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); 725 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end();
714 } 726 }
OLDNEW
« chrome/browser/ui/browser.cc ('K') | « content/renderer/render_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698