| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/low_memory_observer.h" | 5 #include "chrome/browser/low_memory_observer.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/chromeos/chromeos_version.h" | 10 #include "base/chromeos/chromeos_version.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::Callback<void(void)> callback = base::Bind(&DiscardTab); | 83 base::Callback<void(void)> callback = base::Bind(&DiscardTab); |
| 84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 85 owner_->ScheduleNextObservation(); | 85 owner_->ScheduleNextObservation(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Sends off a discard request to the OomPriorityManager. Must be run on | 88 // Sends off a discard request to the OomPriorityManager. Must be run on |
| 89 // the UI thread. | 89 // the UI thread. |
| 90 static void DiscardTab() { | 90 static void DiscardTab() { |
| 91 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 91 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 92 if (g_browser_process && g_browser_process->oom_priority_manager()) | 92 if (g_browser_process && g_browser_process->oom_priority_manager()) |
| 93 g_browser_process->oom_priority_manager()->DiscardTab(); | 93 g_browser_process->oom_priority_manager()->LogMemoryAndDiscardTab(); |
| 94 } | 94 } |
| 95 private: | 95 private: |
| 96 LowMemoryObserverImpl* owner_; | 96 LowMemoryObserverImpl* owner_; |
| 97 DISALLOW_COPY_AND_ASSIGN(FileWatcherDelegate); | 97 DISALLOW_COPY_AND_ASSIGN(FileWatcherDelegate); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 scoped_ptr<MessageLoopForIO::FileDescriptorWatcher> watcher_; | 100 scoped_ptr<MessageLoopForIO::FileDescriptorWatcher> watcher_; |
| 101 FileWatcherDelegate watcher_delegate_; | 101 FileWatcherDelegate watcher_delegate_; |
| 102 int file_descriptor_; | 102 int file_descriptor_; |
| 103 base::OneShotTimer<LowMemoryObserverImpl> timer_; | 103 base::OneShotTimer<LowMemoryObserverImpl> timer_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 void LowMemoryObserver::Stop() { | 175 void LowMemoryObserver::Stop() { |
| 176 BrowserThread::PostTask( | 176 BrowserThread::PostTask( |
| 177 BrowserThread::FILE, | 177 BrowserThread::FILE, |
| 178 FROM_HERE, | 178 FROM_HERE, |
| 179 base::Bind(&LowMemoryObserverImpl::StopObservingOnFileThread, | 179 base::Bind(&LowMemoryObserverImpl::StopObservingOnFileThread, |
| 180 observer_.get())); | 180 observer_.get())); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace browser | 183 } // namespace browser |
| OLD | NEW |