| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/test_extension_prefs.h" | 5 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void TestExtensionPrefs::RecreateExtensionPrefs() { | 64 void TestExtensionPrefs::RecreateExtensionPrefs() { |
| 65 // We persist and reload the PrefService's PrefStores because this process | 65 // We persist and reload the PrefService's PrefStores because this process |
| 66 // deletes all empty dictionaries. The ExtensionPrefs implementation | 66 // deletes all empty dictionaries. The ExtensionPrefs implementation |
| 67 // needs to be able to handle this situation. | 67 // needs to be able to handle this situation. |
| 68 if (pref_service_.get()) { | 68 if (pref_service_.get()) { |
| 69 // The PrefService writes its persistent file on the file thread, so we | 69 // The PrefService writes its persistent file on the file thread, so we |
| 70 // need to wait for any pending I/O to complete before creating a new | 70 // need to wait for any pending I/O to complete before creating a new |
| 71 // PrefService. | 71 // PrefService. |
| 72 base::WaitableEvent io_finished(false, false); | 72 base::WaitableEvent io_finished(false, false); |
| 73 pref_service_->SavePersistentPrefs(); | 73 pref_service_->CommitPendingWrite(); |
| 74 EXPECT_TRUE(BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 74 EXPECT_TRUE(BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 75 new SignalingTask(&io_finished))); | 75 new SignalingTask(&io_finished))); |
| 76 | 76 |
| 77 // If the FILE thread is in fact the current thread (possible in testing | 77 // If the FILE thread is in fact the current thread (possible in testing |
| 78 // scenarios), we have to ensure the task has a chance to run. If the FILE | 78 // scenarios), we have to ensure the task has a chance to run. If the FILE |
| 79 // thread is a different thread, the test must ensure that thread is running | 79 // thread is a different thread, the test must ensure that thread is running |
| 80 // (otherwise the Wait below will hang). | 80 // (otherwise the Wait below will hang). |
| 81 MessageLoop::current()->RunAllPending(); | 81 MessageLoop::current()->RunAllPending(); |
| 82 | 82 |
| 83 EXPECT_TRUE(io_finished.Wait()); | 83 EXPECT_TRUE(io_finished.Wait()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { | 149 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { |
| 150 return pref_service_->CreateIncognitoPrefService( | 150 return pref_service_->CreateIncognitoPrefService( |
| 151 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 151 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 154 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
| 155 extensions_disabled_ = extensions_disabled; | 155 extensions_disabled_ = extensions_disabled; |
| 156 } | 156 } |
| OLD | NEW |