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

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();
asargent_no_longer_on_chrome 2011/03/09 18:13:01 The code before was waiting for the file loop to r
Paweł Hajdan Jr. 2011/03/09 18:22:14 There can be only one MessageLoop per thread. My i
asargent_no_longer_on_chrome 2011/03/09 18:33:25 But it was registering file_loop as the message lo
Paweł Hajdan Jr. 2011/03/09 20:40:03 After a more detailed look I think MessageLoop::cu
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
« no previous file with comments | « chrome/browser/extensions/extension_updater_unittest.cc ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698