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

Unified Diff: chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc

Issue 16703025: [StorageMonitor] Move StorageMonitor ownership to BrowserProcessImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set storage monitor in browser process for unit tests. etc. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc
diff --git a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc
index a8c82a52dc624eb5ca5e6951cc492e20b79eec9d..f7298f160ef66eb4c28eeb690101020a0a1d2b68 100644
--- a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc
+++ b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc
@@ -23,6 +23,8 @@
#include "chrome/browser/storage_monitor/storage_info.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
#include "chrome/browser/storage_monitor/test_media_transfer_protocol_manager_linux.h"
+#include "chrome/browser/storage_monitor/test_storage_monitor.h"
+#include "chrome/test/base/testing_browser_process.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -181,8 +183,12 @@ class StorageMonitorLinuxTest : public testing::Test {
arraysize(initial_test_data),
true /* overwrite */);
- // Initialize the test subject.
- monitor_.reset(new TestStorageMonitorLinux(mtab_file_, &message_loop_));
+ test::TestStorageMonitor::RemoveSingleton();
+ monitor_ = new TestStorageMonitorLinux(mtab_file_, &message_loop_);
+ TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
+ if (browser_process)
+ browser_process->SetStorageMonitor(monitor_);
+
mock_storage_observer_.reset(new MockRemovableStorageObserver);
monitor_->AddObserver(mock_storage_observer_.get());
@@ -193,7 +199,6 @@ class StorageMonitorLinuxTest : public testing::Test {
virtual void TearDown() OVERRIDE {
base::RunLoop().RunUntilIdle();
monitor_->RemoveObserver(mock_storage_observer_.get());
- monitor_.reset();
base::RunLoop().RunUntilIdle();
}
@@ -243,7 +248,7 @@ class StorageMonitorLinuxTest : public testing::Test {
}
StorageMonitor* notifier() {
- return monitor_.get();
+ return monitor_;
}
uint64 GetStorageSize(const base::FilePath& path) {
@@ -316,7 +321,8 @@ class StorageMonitorLinuxTest : public testing::Test {
// Path to the test mtab file.
base::FilePath mtab_file_;
- scoped_ptr<TestStorageMonitorLinux> monitor_;
+ // Weak ptr to the storage monitor. Owned by TestingBrowserProcess.
+ TestStorageMonitorLinux* monitor_;
DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinuxTest);
};

Powered by Google App Engine
This is Rietveld 408576698