| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/profiles/profile_info_cache.h" | 20 #include "chrome/browser/profiles/profile_info_cache.h" |
| 20 #include "chrome/browser/sessions/session_service_factory.h" | 21 #include "chrome/browser/sessions/session_service_factory.h" |
| 21 #include "chrome/browser/sync/profile_sync_service.h" | 22 #include "chrome/browser/sync/profile_sync_service.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 569 } |
| 569 | 570 |
| 570 // static | 571 // static |
| 571 bool ProfileManager::IsMultipleProfilesEnabled() { | 572 bool ProfileManager::IsMultipleProfilesEnabled() { |
| 572 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 573 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) |
| 573 return true; | 574 return true; |
| 574 #else | 575 #else |
| 575 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); | 576 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); |
| 576 #endif | 577 #endif |
| 577 } | 578 } |
| 579 |
| 580 void ProfileManager::ClearAppCaches() { |
| 581 // The WaitableEvent returned by Profile::ClearAppCache() is alive as long as |
| 582 // the Profile is alive. In the future, the Profiles will be deleted earlier |
| 583 // than currently (see |
| 584 // http://code.google.com/p/chromium/issues/detail?id=88586 ). In that case, |
| 585 // Profile::ClearAppCache() must be called when the deletion of the Profile is |
| 586 // initiated, and the Profile can only be deleted after it has finished. A |
| 587 // WaitableEventWatcher can be used for detecting when it has finished. |
| 588 std::map<FilePath, linked_ptr<ProfileInfo> >::iterator it; |
| 589 for (it = profiles_info_.begin(); it != profiles_info_.end(); ++it) { |
| 590 base::WaitableEvent* event = it->second->profile->ClearAppCache(); |
| 591 if (event) |
| 592 event->Wait(); |
| 593 } |
| 594 } |
| OLD | NEW |