| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profile_manager.h" | 7 #include "chrome/browser/profile_manager.h" |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void ProfileManager::OnResume() { | 229 void ProfileManager::OnResume() { |
| 230 DCHECK(CalledOnValidThread()); | 230 DCHECK(CalledOnValidThread()); |
| 231 for (const_iterator i(begin()); i != end(); ++i) { | 231 for (const_iterator i(begin()); i != end(); ++i) { |
| 232 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 232 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 233 NewRunnableFunction(&ProfileManager::ResumeProfile, *i)); | 233 NewRunnableFunction(&ProfileManager::ResumeProfile, *i)); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 void ProfileManager::SuspendProfile(Profile* profile) { | 237 void ProfileManager::SuspendProfile(Profile* profile) { |
| 238 DCHECK(profile); | 238 DCHECK(profile); |
| 239 DCHECK(MessageLoop::current() == | 239 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 240 ChromeThread::GetMessageLoop(ChromeThread::IO)); | |
| 241 | 240 |
| 242 for (URLRequestJobTracker::JobIterator i = g_url_request_job_tracker.begin(); | 241 for (URLRequestJobTracker::JobIterator i = g_url_request_job_tracker.begin(); |
| 243 i != g_url_request_job_tracker.end(); ++i) | 242 i != g_url_request_job_tracker.end(); ++i) |
| 244 (*i)->Kill(); | 243 (*i)->Kill(); |
| 245 | 244 |
| 246 profile->GetRequestContext()->GetURLRequestContext()-> | 245 profile->GetRequestContext()->GetURLRequestContext()-> |
| 247 http_transaction_factory()->Suspend(true); | 246 http_transaction_factory()->Suspend(true); |
| 248 } | 247 } |
| 249 | 248 |
| 250 void ProfileManager::ResumeProfile(Profile* profile) { | 249 void ProfileManager::ResumeProfile(Profile* profile) { |
| 251 DCHECK(profile); | 250 DCHECK(profile); |
| 252 DCHECK(MessageLoop::current() == | 251 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 253 ChromeThread::GetMessageLoop(ChromeThread::IO)); | |
| 254 profile->GetRequestContext()->GetURLRequestContext()-> | 252 profile->GetRequestContext()->GetURLRequestContext()-> |
| 255 http_transaction_factory()->Suspend(false); | 253 http_transaction_factory()->Suspend(false); |
| 256 } | 254 } |
| 257 | 255 |
| 258 | |
| 259 | |
| 260 // static | 256 // static |
| 261 bool ProfileManager::IsProfile(const FilePath& path) { | 257 bool ProfileManager::IsProfile(const FilePath& path) { |
| 262 FilePath prefs_path = GetDefaultProfilePath(path); | 258 FilePath prefs_path = GetDefaultProfilePath(path); |
| 263 | 259 |
| 264 FilePath history_path = path; | 260 FilePath history_path = path; |
| 265 history_path = history_path.Append(chrome::kHistoryFilename); | 261 history_path = history_path.Append(chrome::kHistoryFilename); |
| 266 | 262 |
| 267 return file_util::PathExists(prefs_path) && | 263 return file_util::PathExists(prefs_path) && |
| 268 file_util::PathExists(history_path); | 264 file_util::PathExists(history_path); |
| 269 } | 265 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 310 |
| 315 return profile; | 311 return profile; |
| 316 } | 312 } |
| 317 | 313 |
| 318 // static | 314 // static |
| 319 std::wstring ProfileManager::CanonicalizeID(const std::wstring& id) { | 315 std::wstring ProfileManager::CanonicalizeID(const std::wstring& id) { |
| 320 std::wstring no_whitespace; | 316 std::wstring no_whitespace; |
| 321 TrimWhitespace(id, TRIM_ALL, &no_whitespace); | 317 TrimWhitespace(id, TRIM_ALL, &no_whitespace); |
| 322 return StringToLowerASCII(no_whitespace); | 318 return StringToLowerASCII(no_whitespace); |
| 323 } | 319 } |
| OLD | NEW |