| OLD | NEW |
| 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 <v8.h> | 7 #include <v8.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 WebRuntimeFeatures::enableSessionStorage( | 566 WebRuntimeFeatures::enableSessionStorage( |
| 567 command_line.HasSwitch(switches::kEnableSessionStorage)); | 567 command_line.HasSwitch(switches::kEnableSessionStorage)); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void RenderThread::IdleHandler() { | 570 void RenderThread::IdleHandler() { |
| 571 // It is possible that the timer was set while the widgets were idle, | 571 // It is possible that the timer was set while the widgets were idle, |
| 572 // but that they are no longer idle. If so, just return. | 572 // but that they are no longer idle. If so, just return. |
| 573 if (!widget_count_ || hidden_widget_count_ < widget_count_) | 573 if (!widget_count_ || hidden_widget_count_ < widget_count_) |
| 574 return; | 574 return; |
| 575 | 575 |
| 576 #if defined(OS_WIN) | 576 #if defined(OS_WIN) && defined(USE_TCMALLOC) |
| 577 MallocExtension::instance()->ReleaseFreeMemory(); | 577 MallocExtension::instance()->ReleaseFreeMemory(); |
| 578 #endif | 578 #endif |
| 579 | 579 |
| 580 LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; | 580 LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; |
| 581 v8::V8::IdleNotification(); | 581 v8::V8::IdleNotification(); |
| 582 | 582 |
| 583 // Schedule next invocation. | 583 // Schedule next invocation. |
| 584 // Dampen the delay using the algorithm: | 584 // Dampen the delay using the algorithm: |
| 585 // delay = delay + 1 / (delay + 2) | 585 // delay = delay + 1 / (delay + 2) |
| 586 // Using floor(delay) has a dampening effect such as: | 586 // Using floor(delay) has a dampening effect such as: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { | 621 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { |
| 622 } | 622 } |
| 623 | 623 |
| 624 // Repeatedly call the V8 idle notification until it returns true ("nothing | 624 // Repeatedly call the V8 idle notification until it returns true ("nothing |
| 625 // more to free"). Note that it makes more sense to do this than to implement | 625 // more to free"). Note that it makes more sense to do this than to implement |
| 626 // a new "delete everything" pass because object references make it difficult | 626 // a new "delete everything" pass because object references make it difficult |
| 627 // to free everything possible in just one pass. | 627 // to free everything possible in just one pass. |
| 628 while (!v8::V8::IdleNotification()) { | 628 while (!v8::V8::IdleNotification()) { |
| 629 } | 629 } |
| 630 | 630 |
| 631 #if defined(OS_WIN) | 631 #if defined(OS_WIN) && defined(USE_TCMALLOC) |
| 632 // Tell tcmalloc to release any free pages it's still holding. | 632 // Tell tcmalloc to release any free pages it's still holding. |
| 633 MallocExtension::instance()->ReleaseFreeMemory(); | 633 MallocExtension::instance()->ReleaseFreeMemory(); |
| 634 #endif | 634 #endif |
| 635 } | 635 } |
| 636 | 636 |
| 637 void RenderThread::OnPurgePluginListCache(bool reload_pages) { | 637 void RenderThread::OnPurgePluginListCache(bool reload_pages) { |
| 638 EnsureWebKitInitialized(); | 638 EnsureWebKitInitialized(); |
| 639 // The call below will cause a GetPlugins call with refresh=true, but at this | 639 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 640 // point we already know that the browser has refreshed its list, so disable | 640 // point we already know that the browser has refreshed its list, so disable |
| 641 // refresh temporarily to prevent each renderer process causing the list to be | 641 // refresh temporarily to prevent each renderer process causing the list to be |
| (...skipping 13 matching lines...) Expand all Loading... |
| 655 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); | 655 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); |
| 656 } | 656 } |
| 657 | 657 |
| 658 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { | 658 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { |
| 659 spellchecker_->WordAdded(word); | 659 spellchecker_->WordAdded(word); |
| 660 } | 660 } |
| 661 | 661 |
| 662 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { | 662 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { |
| 663 spellchecker_->EnableAutoSpellCorrect(enable); | 663 spellchecker_->EnableAutoSpellCorrect(enable); |
| 664 } | 664 } |
| OLD | NEW |