| 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 "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" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 FilePath GetCachePath(const FilePath& base) { | 162 FilePath GetCachePath(const FilePath& base) { |
| 163 return base.Append(chrome::kCacheDirname); | 163 return base.Append(chrome::kCacheDirname); |
| 164 } | 164 } |
| 165 | 165 |
| 166 FilePath GetMediaCachePath(const FilePath& base) { | 166 FilePath GetMediaCachePath(const FilePath& base) { |
| 167 return base.Append(chrome::kMediaCacheDirname); | 167 return base.Append(chrome::kMediaCacheDirname); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void SaveSessionStateOnIOThread( |
| 171 net::URLRequestContextGetter* url_request_context_getter) { |
| 172 url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
| 173 GetCookieMonster()->SaveSessionCookies(); |
| 174 } |
| 175 |
| 176 void RestoreSessionStateOnIOThread( |
| 177 net::URLRequestContextGetter* url_request_context_getter) { |
| 178 url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
| 179 GetCookieMonster()->RestoreOldSessionCookies(); |
| 180 } |
| 181 |
| 182 void DiscardSessionStateOnIOThread( |
| 183 net::URLRequestContextGetter* url_request_context_getter) { |
| 184 url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
| 185 GetCookieMonster()->DiscardOldSessionCookies(); |
| 186 } |
| 187 |
| 170 } // namespace | 188 } // namespace |
| 171 | 189 |
| 172 // static | 190 // static |
| 173 Profile* Profile::CreateProfile(const FilePath& path) { | 191 Profile* Profile::CreateProfile(const FilePath& path) { |
| 174 if (!file_util::PathExists(path)) { | 192 if (!file_util::PathExists(path)) { |
| 175 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 193 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
| 176 // profile directory. We should eventually be able to run in this | 194 // profile directory. We should eventually be able to run in this |
| 177 // situation. | 195 // situation. |
| 178 if (!file_util::CreateDirectory(path)) | 196 if (!file_util::CreateDirectory(path)) |
| 179 return NULL; | 197 return NULL; |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 return GURL(chrome::kChromeUINewTabURL); | 1562 return GURL(chrome::kChromeUINewTabURL); |
| 1545 return home_page; | 1563 return home_page; |
| 1546 } | 1564 } |
| 1547 | 1565 |
| 1548 NetworkActionPredictor* ProfileImpl::GetNetworkActionPredictor() { | 1566 NetworkActionPredictor* ProfileImpl::GetNetworkActionPredictor() { |
| 1549 if (!network_action_predictor_.get()) | 1567 if (!network_action_predictor_.get()) |
| 1550 network_action_predictor_.reset(new NetworkActionPredictor(this)); | 1568 network_action_predictor_.reset(new NetworkActionPredictor(this)); |
| 1551 return network_action_predictor_.get(); | 1569 return network_action_predictor_.get(); |
| 1552 } | 1570 } |
| 1553 | 1571 |
| 1572 void ProfileImpl::SaveSessionState() { |
| 1573 BrowserThread::PostTask( |
| 1574 BrowserThread::IO, FROM_HERE, |
| 1575 base::Bind(&SaveSessionStateOnIOThread, |
| 1576 make_scoped_refptr(GetRequestContext()))); |
| 1577 } |
| 1578 |
| 1579 void ProfileImpl::RestoreSessionState() { |
| 1580 BrowserThread::PostTask( |
| 1581 BrowserThread::IO, FROM_HERE, |
| 1582 base::Bind(&RestoreSessionStateOnIOThread, |
| 1583 make_scoped_refptr(GetRequestContext()))); |
| 1584 } |
| 1585 |
| 1586 void ProfileImpl::DiscardSessionState() { |
| 1587 BrowserThread::PostTask( |
| 1588 BrowserThread::IO, FROM_HERE, |
| 1589 base::Bind(&DiscardSessionStateOnIOThread, |
| 1590 make_scoped_refptr(GetRequestContext()))); |
| 1591 } |
| 1592 |
| 1554 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1593 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
| 1555 if (!spellcheck_profile_.get()) | 1594 if (!spellcheck_profile_.get()) |
| 1556 spellcheck_profile_.reset(new SpellCheckProfile(path_)); | 1595 spellcheck_profile_.reset(new SpellCheckProfile(path_)); |
| 1557 return spellcheck_profile_.get(); | 1596 return spellcheck_profile_.get(); |
| 1558 } | 1597 } |
| 1559 | 1598 |
| 1560 void ProfileImpl::UpdateProfileUserNameCache() { | 1599 void ProfileImpl::UpdateProfileUserNameCache() { |
| 1561 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1600 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1562 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1601 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1563 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1602 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1577 FilePath* cache_path, | 1616 FilePath* cache_path, |
| 1578 int* max_size) { | 1617 int* max_size) { |
| 1579 DCHECK(cache_path); | 1618 DCHECK(cache_path); |
| 1580 DCHECK(max_size); | 1619 DCHECK(max_size); |
| 1581 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1620 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
| 1582 if (!path.empty()) | 1621 if (!path.empty()) |
| 1583 *cache_path = path; | 1622 *cache_path = path; |
| 1584 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1623 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1585 prefs_->GetInteger(prefs::kDiskCacheSize); | 1624 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1586 } | 1625 } |
| OLD | NEW |