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

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

Issue 267021: Add functionality to the renderer thread to purge memory. Not yet called.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/render_thread.h" 5 #include "chrome/renderer/render_thread.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 28 matching lines...) Expand all
39 #include "chrome/renderer/external_extension.h" 39 #include "chrome/renderer/external_extension.h"
40 #include "chrome/renderer/loadtimes_extension_bindings.h" 40 #include "chrome/renderer/loadtimes_extension_bindings.h"
41 #include "chrome/renderer/net/render_dns_master.h" 41 #include "chrome/renderer/net/render_dns_master.h"
42 #include "chrome/renderer/render_process.h" 42 #include "chrome/renderer/render_process.h"
43 #include "chrome/renderer/render_view.h" 43 #include "chrome/renderer/render_view.h"
44 #include "chrome/renderer/renderer_webkitclient_impl.h" 44 #include "chrome/renderer/renderer_webkitclient_impl.h"
45 #include "chrome/renderer/user_script_slave.h" 45 #include "chrome/renderer/user_script_slave.h"
46 #include "ipc/ipc_message.h" 46 #include "ipc/ipc_message.h"
47 #include "webkit/api/public/WebCache.h" 47 #include "webkit/api/public/WebCache.h"
48 #include "webkit/api/public/WebColor.h" 48 #include "webkit/api/public/WebColor.h"
49 #include "webkit/api/public/WebCrossOriginPreflightResultCache.h"
50 #include "webkit/api/public/WebFontCache.h"
51 #include "webkit/api/public/WebColor.h"
49 #include "webkit/api/public/WebKit.h" 52 #include "webkit/api/public/WebKit.h"
50 #include "webkit/api/public/WebStorageEventDispatcher.h" 53 #include "webkit/api/public/WebStorageEventDispatcher.h"
51 #include "webkit/api/public/WebString.h" 54 #include "webkit/api/public/WebString.h"
52 #include "webkit/extensions/v8/benchmarking_extension.h" 55 #include "webkit/extensions/v8/benchmarking_extension.h"
53 #include "webkit/extensions/v8/gears_extension.h" 56 #include "webkit/extensions/v8/gears_extension.h"
54 #include "webkit/extensions/v8/interval_extension.h" 57 #include "webkit/extensions/v8/interval_extension.h"
55 #include "webkit/extensions/v8/playback_extension.h" 58 #include "webkit/extensions/v8/playback_extension.h"
56 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h" 59 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h"
57 60
58 #if defined(OS_WIN) 61 #if defined(OS_WIN)
59 #include <windows.h> 62 #include <windows.h>
60 #include <objbase.h> 63 #include <objbase.h>
61 #endif 64 #endif
62 65
63 using WebKit::WebCache; 66 using WebKit::WebCache;
67 using WebKit::WebCrossOriginPreflightResultCache;
68 using WebKit::WebFontCache;
64 using WebKit::WebString; 69 using WebKit::WebString;
65 using WebKit::WebStorageEventDispatcher; 70 using WebKit::WebStorageEventDispatcher;
66 71
67 namespace { 72 namespace {
68 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; 73 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
69 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; 74 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */;
70 75
71 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( 76 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls(
72 base::LINKER_INITIALIZED); 77 base::LINKER_INITIALIZED);
73 78
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, 285 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats,
281 OnGetCacheResourceStats) 286 OnGetCacheResourceStats)
282 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, 287 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts,
283 OnUpdateUserScripts) 288 OnUpdateUserScripts)
284 // TODO(rafaelw): create an ExtensionDispatcher that handles extension 289 // TODO(rafaelw): create an ExtensionDispatcher that handles extension
285 // messages seperates their handling from the RenderThread. 290 // messages seperates their handling from the RenderThread.
286 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, 291 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke,
287 OnExtensionMessageInvoke) 292 OnExtensionMessageInvoke)
288 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, 293 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
289 OnSetExtensionFunctionNames) 294 OnSetExtensionFunctionNames)
295 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
290 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, 296 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
291 OnPurgePluginListCache) 297 OnPurgePluginListCache)
292 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions, 298 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions,
293 OnPageActionsUpdated) 299 OnPageActionsUpdated)
294 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions, 300 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions,
295 OnExtensionSetAPIPermissions) 301 OnExtensionSetAPIPermissions)
296 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, 302 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions,
297 OnExtensionSetHostPermissions) 303 OnExtensionSetHostPermissions)
298 IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent, 304 IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent,
299 OnDOMStorageEvent) 305 OnDOMStorageEvent)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 MessageLoop::current()->PostDelayedTask(FROM_HERE, 508 MessageLoop::current()->PostDelayedTask(FROM_HERE,
503 task_factory_->NewRunnableMethod(&RenderThread::IdleHandler), 509 task_factory_->NewRunnableMethod(&RenderThread::IdleHandler),
504 static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000); 510 static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000);
505 } 511 }
506 512
507 void RenderThread::OnExtensionMessageInvoke(const std::string& function_name, 513 void RenderThread::OnExtensionMessageInvoke(const std::string& function_name,
508 const ListValue& args) { 514 const ListValue& args) {
509 RendererExtensionBindings::Invoke(function_name, args, NULL); 515 RendererExtensionBindings::Invoke(function_name, args, NULL);
510 } 516 }
511 517
518 void RenderThread::OnPurgeMemory() {
519 EnsureWebKitInitialized();
520
521 // Clear the object cache (as much as possible; some live objects cannot be
522 // freed).
523 WebCache::clear();
524
525 // Clear the font/glyph cache.
526 WebFontCache::clear();
527
528 // Clear the Cross-Origin Preflight cache.
529 WebCrossOriginPreflightResultCache::clear();
530
531 // Repeatedly call the V8 idle notification until it returns true ("nothing
532 // more to free"). Note that it makes more sense to do this than to implement
533 // a new "delete everything" pass because object references make it difficult
534 // to free everything possible in just one pass.
535 while (!v8::V8::IdleNotification())
536 ;
537
538 #if defined(OS_WIN)
539 // Tell tcmalloc to release any free pages it's still holding.
540 MallocExtension::instance()->ReleaseFreeMemory();
541 #endif
542 }
543
512 void RenderThread::OnPurgePluginListCache(bool reload_pages) { 544 void RenderThread::OnPurgePluginListCache(bool reload_pages) {
513 EnsureWebKitInitialized(); 545 EnsureWebKitInitialized();
514 // The call below will cause a GetPlugins call with refresh=true, but at this 546 // The call below will cause a GetPlugins call with refresh=true, but at this
515 // point we already know that the browser has refreshed its list, so disable 547 // point we already know that the browser has refreshed its list, so disable
516 // refresh temporarily to prevent each renderer process causing the list to be 548 // refresh temporarily to prevent each renderer process causing the list to be
517 // regenerated. 549 // regenerated.
518 plugin_refresh_allowed_ = false; 550 plugin_refresh_allowed_ = false;
519 WebKit::resetPluginCache(reload_pages); 551 WebKit::resetPluginCache(reload_pages);
520 plugin_refresh_allowed_ = true; 552 plugin_refresh_allowed_ = true;
521 } 553 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698