| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <v8.h> | 7 #include <v8.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> |
| 10 #include <map> | 11 #include <map> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #if defined(USE_SYSTEM_SQLITE) | 14 #if defined(USE_SYSTEM_SQLITE) |
| 14 #include <sqlite3.h> | 15 #include <sqlite3.h> |
| 15 #else | 16 #else |
| 16 #include "third_party/sqlite/preprocessed/sqlite3.h" | 17 #include "third_party/sqlite/preprocessed/sqlite3.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 366 |
| 366 void RenderThread::WidgetHidden() { | 367 void RenderThread::WidgetHidden() { |
| 367 DCHECK(hidden_widget_count_ < widget_count_); | 368 DCHECK(hidden_widget_count_ < widget_count_); |
| 368 hidden_widget_count_++; | 369 hidden_widget_count_++; |
| 369 if (!is_extension_process() && | 370 if (!is_extension_process() && |
| 370 widget_count_ && hidden_widget_count_ == widget_count_) | 371 widget_count_ && hidden_widget_count_ == widget_count_) |
| 371 ScheduleIdleHandler(kInitialIdleHandlerDelayS); | 372 ScheduleIdleHandler(kInitialIdleHandlerDelayS); |
| 372 } | 373 } |
| 373 | 374 |
| 374 void RenderThread::WidgetRestored() { | 375 void RenderThread::WidgetRestored() { |
| 375 DCHECK(hidden_widget_count_ > 0); | 376 DCHECK_GT(hidden_widget_count_, 0); |
| 376 hidden_widget_count_--; | 377 hidden_widget_count_--; |
| 377 if (!is_extension_process()) | 378 if (!is_extension_process()) |
| 378 idle_timer_.Stop(); | 379 idle_timer_.Stop(); |
| 379 } | 380 } |
| 380 | 381 |
| 381 void RenderThread::DoNotSuspendWebKitSharedTimer() { | 382 void RenderThread::DoNotSuspendWebKitSharedTimer() { |
| 382 do_not_suspend_webkit_shared_timer_ = true; | 383 do_not_suspend_webkit_shared_timer_ = true; |
| 383 } | 384 } |
| 384 | 385 |
| 385 void RenderThread::DoNotNotifyWebKitOfModalLoop() { | 386 void RenderThread::DoNotNotifyWebKitOfModalLoop() { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 !command_line.HasSwitch(switches::kDisableSessionStorage)); | 766 !command_line.HasSwitch(switches::kDisableSessionStorage)); |
| 766 | 767 |
| 767 WebRuntimeFeatures::enableIndexedDatabase( | 768 WebRuntimeFeatures::enableIndexedDatabase( |
| 768 command_line.HasSwitch(switches::kEnableIndexedDatabase)); | 769 command_line.HasSwitch(switches::kEnableIndexedDatabase)); |
| 769 | 770 |
| 770 WebRuntimeFeatures::enableGeolocation( | 771 WebRuntimeFeatures::enableGeolocation( |
| 771 command_line.HasSwitch(switches::kEnableGeolocation)); | 772 command_line.HasSwitch(switches::kEnableGeolocation)); |
| 772 } | 773 } |
| 773 | 774 |
| 774 void RenderThread::IdleHandler() { | 775 void RenderThread::IdleHandler() { |
| 775 #if defined(OS_WIN) && defined(USE_TCMALLOC) | 776 #if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC) |
| 776 MallocExtension::instance()->ReleaseFreeMemory(); | 777 MallocExtension::instance()->ReleaseFreeMemory(); |
| 777 #endif | 778 #endif |
| 778 | 779 |
| 779 LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; | 780 LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; |
| 780 v8::V8::IdleNotification(); | 781 v8::V8::IdleNotification(); |
| 781 | 782 |
| 782 // Schedule next invocation. | 783 // Schedule next invocation. |
| 783 // Dampen the delay using the algorithm: | 784 // Dampen the delay using the algorithm: |
| 784 // delay = delay + 1 / (delay + 2) | 785 // delay = delay + 1 / (delay + 2) |
| 785 // Using floor(delay) has a dampening effect such as: | 786 // Using floor(delay) has a dampening effect such as: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { | 840 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { |
| 840 } | 841 } |
| 841 | 842 |
| 842 // Repeatedly call the V8 idle notification until it returns true ("nothing | 843 // Repeatedly call the V8 idle notification until it returns true ("nothing |
| 843 // more to free"). Note that it makes more sense to do this than to implement | 844 // more to free"). Note that it makes more sense to do this than to implement |
| 844 // a new "delete everything" pass because object references make it difficult | 845 // a new "delete everything" pass because object references make it difficult |
| 845 // to free everything possible in just one pass. | 846 // to free everything possible in just one pass. |
| 846 while (!v8::V8::IdleNotification()) { | 847 while (!v8::V8::IdleNotification()) { |
| 847 } | 848 } |
| 848 | 849 |
| 849 #if defined(OS_WIN) && defined(USE_TCMALLOC) | 850 #if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC) |
| 850 // Tell tcmalloc to release any free pages it's still holding. | 851 // Tell tcmalloc to release any free pages it's still holding. |
| 851 MallocExtension::instance()->ReleaseFreeMemory(); | 852 MallocExtension::instance()->ReleaseFreeMemory(); |
| 852 #endif | 853 #endif |
| 853 } | 854 } |
| 854 | 855 |
| 855 void RenderThread::OnPurgePluginListCache(bool reload_pages) { | 856 void RenderThread::OnPurgePluginListCache(bool reload_pages) { |
| 856 EnsureWebKitInitialized(); | 857 EnsureWebKitInitialized(); |
| 857 // The call below will cause a GetPlugins call with refresh=true, but at this | 858 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 858 // point we already know that the browser has refreshed its list, so disable | 859 // point we already know that the browser has refreshed its list, so disable |
| 859 // refresh temporarily to prevent each renderer process causing the list to be | 860 // refresh temporarily to prevent each renderer process causing the list to be |
| (...skipping 13 matching lines...) Expand all Loading... |
| 873 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); | 874 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); |
| 874 } | 875 } |
| 875 | 876 |
| 876 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { | 877 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { |
| 877 spellchecker_->WordAdded(word); | 878 spellchecker_->WordAdded(word); |
| 878 } | 879 } |
| 879 | 880 |
| 880 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { | 881 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { |
| 881 spellchecker_->EnableAutoSpellCorrect(enable); | 882 spellchecker_->EnableAutoSpellCorrect(enable); |
| 882 } | 883 } |
| OLD | NEW |