OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_tokenizer.h" | 16 #include "base/string_tokenizer.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/threading/sequenced_worker_pool.h" | |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "base/version.h" | 21 #include "base/version.h" |
21 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 22 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
22 #include "chrome/browser/background/background_contents_service_factory.h" | 23 #include "chrome/browser/background/background_contents_service_factory.h" |
23 #include "chrome/browser/background/background_mode_manager.h" | 24 #include "chrome/browser/background/background_mode_manager.h" |
24 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chrome_plugin_service_filter.h" | 26 #include "chrome/browser/chrome_plugin_service_filter.h" |
26 #include "chrome/browser/content_settings/cookie_settings.h" | 27 #include "chrome/browser/content_settings/cookie_settings.h" |
27 #include "chrome/browser/content_settings/host_content_settings_map.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map.h" |
28 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 } | 204 } |
204 | 205 |
205 } // namespace | 206 } // namespace |
206 | 207 |
207 // static | 208 // static |
208 Profile* Profile::CreateProfile(const FilePath& path, | 209 Profile* Profile::CreateProfile(const FilePath& path, |
209 Delegate* delegate, | 210 Delegate* delegate, |
210 CreateMode create_mode) { | 211 CreateMode create_mode) { |
211 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 212 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
212 DCHECK(delegate); | 213 DCHECK(delegate); |
213 // This is safe while all file operations are done on the FILE thread. | 214 // We need to make sure that profile directory is created on the same |
214 BrowserThread::PostTask( | 215 // blocking pool where we will run all its important file serialization |
215 BrowserThread::FILE, FROM_HERE, | 216 // tasks (i.e. JsonPrefStore). |
216 base::Bind(&CreateDirectoryNoResult, path)); | 217 scoped_refptr<base::SequencedTaskRunner> task_runner = |
218 BrowserThread::GetBlockingPool()-> | |
219 GetSequencedTaskRunnerWithShutdownBehavior( | |
220 BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | |
221 path.AsUTF8Unsafe()), | |
willchan no longer on Chromium
2012/10/11 23:19:31
The only thing that makes me feel nervous about th
zel
2012/10/12 23:15:32
I have isolated SequencedTaskRunner and shared it
| |
222 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | |
223 task_runner->PostTask(FROM_HERE, | |
224 base::Bind(&CreateDirectoryNoResult, path)); | |
217 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) { | 225 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) { |
218 if (!file_util::PathExists(path)) { | 226 if (!file_util::PathExists(path)) { |
219 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 227 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
220 // profile directory. We should eventually be able to run in this | 228 // profile directory. We should eventually be able to run in this |
221 // situation. | 229 // situation. |
222 if (!file_util::CreateDirectory(path)) | 230 if (!file_util::CreateDirectory(path)) |
223 return NULL; | 231 return NULL; |
224 } | 232 } |
225 } else { | 233 } else { |
226 NOTREACHED(); | 234 NOTREACHED(); |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 if (!path.empty()) | 1149 if (!path.empty()) |
1142 *cache_path = path; | 1150 *cache_path = path; |
1143 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1151 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1144 prefs_->GetInteger(prefs::kDiskCacheSize); | 1152 prefs_->GetInteger(prefs::kDiskCacheSize); |
1145 } | 1153 } |
1146 | 1154 |
1147 base::Callback<ChromeURLDataManagerBackend*(void)> | 1155 base::Callback<ChromeURLDataManagerBackend*(void)> |
1148 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1156 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
1149 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1157 return io_data_.GetChromeURLDataManagerBackendGetter(); |
1150 } | 1158 } |
OLD | NEW |