| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 void TestExtensionPrefs::RecreateExtensionPrefs() { | 67 void TestExtensionPrefs::RecreateExtensionPrefs() { |
| 68 // We persist and reload the PrefService's PrefStores because this process | 68 // We persist and reload the PrefService's PrefStores because this process |
| 69 // deletes all empty dictionaries. The ExtensionPrefs implementation | 69 // deletes all empty dictionaries. The ExtensionPrefs implementation |
| 70 // needs to be able to handle this situation. | 70 // needs to be able to handle this situation. |
| 71 if (pref_service_.get()) { | 71 if (pref_service_.get()) { |
| 72 // The PrefService writes its persistent file on the file thread, so we | 72 // The PrefService writes its persistent file on the file thread, so we |
| 73 // need to wait for any pending I/O to complete before creating a new | 73 // need to wait for any pending I/O to complete before creating a new |
| 74 // PrefService. | 74 // PrefService. |
| 75 base::WaitableEvent io_finished(false, false); | 75 base::WaitableEvent io_finished(false, false); |
| 76 pref_service_->SavePersistentPrefs(); | 76 pref_service_-> CommitPendingWrite(); |
| 77 EXPECT_TRUE(BrowserThread::PostTask( | 77 EXPECT_TRUE(BrowserThread::PostTask( |
| 78 BrowserThread::FILE, | 78 BrowserThread::FILE, |
| 79 FROM_HERE, | 79 FROM_HERE, |
| 80 base::Bind(&base::WaitableEvent::Signal, | 80 base::Bind(&base::WaitableEvent::Signal, |
| 81 base::Unretained(&io_finished)))); | 81 base::Unretained(&io_finished)))); |
| 82 | 82 |
| 83 // If the FILE thread is in fact the current thread (possible in testing | 83 // If the FILE thread is in fact the current thread (possible in testing |
| 84 // scenarios), we have to ensure the task has a chance to run. If the FILE | 84 // scenarios), we have to ensure the task has a chance to run. If the FILE |
| 85 // thread is a different thread, the test must ensure that thread is running | 85 // thread is a different thread, the test must ensure that thread is running |
| 86 // (otherwise the Wait below will hang). | 86 // (otherwise the Wait below will hang). |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { | 156 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { |
| 157 return pref_service_->CreateIncognitoPrefService( | 157 return pref_service_->CreateIncognitoPrefService( |
| 158 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 158 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 161 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
| 162 extensions_disabled_ = extensions_disabled; | 162 extensions_disabled_ = extensions_disabled; |
| 163 } | 163 } |
| OLD | NEW |