| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 // Value written to prefs for EXIT_CRASHED and EXIT_SESSION_ENDED. | 168 // Value written to prefs for EXIT_CRASHED and EXIT_SESSION_ENDED. |
| 169 const char* const kPrefExitTypeCrashed = "Crashed"; | 169 const char* const kPrefExitTypeCrashed = "Crashed"; |
| 170 const char* const kPrefExitTypeSessionEnded = "SessionEnded"; | 170 const char* const kPrefExitTypeSessionEnded = "SessionEnded"; |
| 171 | 171 |
| 172 // Helper method needed because PostTask cannot currently take a Callback | 172 // Helper method needed because PostTask cannot currently take a Callback |
| 173 // function with non-void return type. | 173 // function with non-void return type. |
| 174 void CreateDirectoryAndSignal(const base::FilePath& path, | 174 void CreateDirectoryAndSignal(const base::FilePath& path, |
| 175 base::WaitableEvent* done_creating) { | 175 base::WaitableEvent* done_creating) { |
| 176 DVLOG(1) << "Creating directory " << path.value(); | 176 DVLOG(1) << "Creating directory " << path.value(); |
| 177 LOG(ERROR) << "JAMES sleeping on create directory"; |
| 178 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(5)); |
| 177 base::CreateDirectory(path); | 179 base::CreateDirectory(path); |
| 178 done_creating->Signal(); | 180 done_creating->Signal(); |
| 179 } | 181 } |
| 180 | 182 |
| 181 // Task that blocks the FILE thread until CreateDirectoryAndSignal() finishes on | 183 // Task that blocks the FILE thread until CreateDirectoryAndSignal() finishes on |
| 182 // blocking I/O pool. | 184 // blocking I/O pool. |
| 183 void BlockFileThreadOnDirectoryCreate(base::WaitableEvent* done_creating) { | 185 void BlockFileThreadOnDirectoryCreate(base::WaitableEvent* done_creating) { |
| 184 done_creating->Wait(); | 186 done_creating->Wait(); |
| 185 } | 187 } |
| 186 | 188 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 "profile_path", | 275 "profile_path", |
| 274 path.value().c_str()); | 276 path.value().c_str()); |
| 275 | 277 |
| 276 // Get sequenced task runner for making sure that file operations of | 278 // Get sequenced task runner for making sure that file operations of |
| 277 // this profile (defined by |path|) are executed in expected order | 279 // this profile (defined by |path|) are executed in expected order |
| 278 // (what was previously assured by the FILE thread). | 280 // (what was previously assured by the FILE thread). |
| 279 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 281 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
| 280 JsonPrefStore::GetTaskRunnerForFile(path, | 282 JsonPrefStore::GetTaskRunnerForFile(path, |
| 281 BrowserThread::GetBlockingPool()); | 283 BrowserThread::GetBlockingPool()); |
| 282 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { | 284 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
| 285 LOG(ERROR) << "JAMES create profile async"; |
| 283 DCHECK(delegate); | 286 DCHECK(delegate); |
| 284 CreateProfileDirectory(sequenced_task_runner.get(), path); | 287 CreateProfileDirectory(sequenced_task_runner.get(), path); |
| 285 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) { | 288 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) { |
| 286 if (!base::PathExists(path)) { | 289 if (!base::PathExists(path)) { |
| 287 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 290 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
| 288 // profile directory. We should eventually be able to run in this | 291 // profile directory. We should eventually be able to run in this |
| 289 // situation. | 292 // situation. |
| 290 if (!base::CreateDirectory(path)) | 293 if (!base::CreateDirectory(path)) |
| 291 return NULL; | 294 return NULL; |
| 292 } | 295 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 true)) { | 642 true)) { |
| 640 return; | 643 return; |
| 641 } | 644 } |
| 642 #endif | 645 #endif |
| 643 | 646 |
| 644 if (delegate_) { | 647 if (delegate_) { |
| 645 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") | 648 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") |
| 646 delegate_->OnProfileCreated(this, true, IsNewProfile()); | 649 delegate_->OnProfileCreated(this, true, IsNewProfile()); |
| 647 } | 650 } |
| 648 | 651 |
| 652 LOG(ERROR) << "JAMES send profile created"; |
| 649 content::NotificationService::current()->Notify( | 653 content::NotificationService::current()->Notify( |
| 650 chrome::NOTIFICATION_PROFILE_CREATED, | 654 chrome::NOTIFICATION_PROFILE_CREATED, |
| 651 content::Source<Profile>(this), | 655 content::Source<Profile>(this), |
| 652 content::NotificationService::NoDetails()); | 656 content::NotificationService::NoDetails()); |
| 653 | 657 |
| 654 #if !defined(OS_CHROMEOS) | 658 #if !defined(OS_CHROMEOS) |
| 655 // Listen for bookmark model load, to bootstrap the sync service. | 659 // Listen for bookmark model load, to bootstrap the sync service. |
| 656 // On CrOS sync service will be initialized after sign in. | 660 // On CrOS sync service will be initialized after sign in. |
| 657 BookmarkModel* model = BookmarkModelFactory::GetForProfile(this); | 661 BookmarkModel* model = BookmarkModelFactory::GetForProfile(this); |
| 658 model->AddObserver(new BookmarkModelLoadedObserver(this)); | 662 model->AddObserver(new BookmarkModelLoadedObserver(this)); |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 ProfileImpl::CreateDomainReliabilityMonitor() { | 1327 ProfileImpl::CreateDomainReliabilityMonitor() { |
| 1324 domain_reliability::DomainReliabilityService* service = | 1328 domain_reliability::DomainReliabilityService* service = |
| 1325 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1329 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
| 1326 GetForBrowserContext(this); | 1330 GetForBrowserContext(this); |
| 1327 if (!service) | 1331 if (!service) |
| 1328 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1332 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1329 | 1333 |
| 1330 return service->CreateMonitor( | 1334 return service->CreateMonitor( |
| 1331 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1335 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 1332 } | 1336 } |
| OLD | NEW |