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

Side by Side Diff: chrome/browser/extensions/test_extension_prefs.cc

Issue 6627060: ImportantFileWriter: check return value of PostTask... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 TestExtensionPrefs::~TestExtensionPrefs() {} 58 TestExtensionPrefs::~TestExtensionPrefs() {}
59 59
60 void TestExtensionPrefs::RecreateExtensionPrefs() { 60 void TestExtensionPrefs::RecreateExtensionPrefs() {
61 // We persist and reload the PrefService's PrefStores because this process 61 // We persist and reload the PrefService's PrefStores because this process
62 // deletes all empty dictionaries. The ExtensionPrefs implementation 62 // deletes all empty dictionaries. The ExtensionPrefs implementation
63 // needs to be able to handle this situation. 63 // needs to be able to handle this situation.
64 if (pref_service_.get()) { 64 if (pref_service_.get()) {
65 // The PrefService writes its persistent file on the file thread, so we 65 // The PrefService writes its persistent file on the file thread, so we
66 // need to wait for any pending I/O to complete before creating a new 66 // need to wait for any pending I/O to complete before creating a new
67 // PrefService. 67 // PrefService.
68 MessageLoop file_loop;
69 BrowserThread file_thread(BrowserThread::FILE, &file_loop);
70 pref_service_->SavePersistentPrefs(); 68 pref_service_->SavePersistentPrefs();
71 file_loop.RunAllPending(); 69 MessageLoop::current()->RunAllPending();
72 } 70 }
73 71
74 extension_pref_value_map_.reset(new ExtensionPrefValueMap); 72 extension_pref_value_map_.reset(new ExtensionPrefValueMap);
75 PrefServiceMockBuilder builder; 73 PrefServiceMockBuilder builder;
76 builder.WithUserFilePrefs(preferences_file_); 74 builder.WithUserFilePrefs(preferences_file_);
77 builder.WithExtensionPrefs( 75 builder.WithExtensionPrefs(
78 new ExtensionPrefStore(extension_pref_value_map_.get(), false)); 76 new ExtensionPrefStore(extension_pref_value_map_.get(), false));
79 pref_service_.reset(builder.Create()); 77 pref_service_.reset(builder.Create());
80 ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); 78 ExtensionPrefs::RegisterUserPrefs(pref_service_.get());
81 79
(...skipping 30 matching lines...) Expand all
112 110
113 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { 111 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) {
114 scoped_refptr<Extension> extension(AddExtension(name)); 112 scoped_refptr<Extension> extension(AddExtension(name));
115 return extension->id(); 113 return extension->id();
116 } 114 }
117 115
118 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { 116 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const {
119 return pref_service_->CreateIncognitoPrefService( 117 return pref_service_->CreateIncognitoPrefService(
120 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); 118 new ExtensionPrefStore(extension_pref_value_map_.get(), true));
121 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698