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/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/deferred_sequenced_task_runner.h" | |
11 #include "base/environment.h" | 12 #include "base/environment.h" |
12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/prefs/json_pref_store.h" | 17 #include "base/prefs/json_pref_store.h" |
17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
18 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
20 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 // Make sure that the ProfileImpl doesn't grow. We're currently trying to drive | 134 // Make sure that the ProfileImpl doesn't grow. We're currently trying to drive |
134 // the number of services that are included in ProfileImpl (instead of using | 135 // the number of services that are included in ProfileImpl (instead of using |
135 // ProfileKeyedServiceFactory) to zero. | 136 // ProfileKeyedServiceFactory) to zero. |
136 // | 137 // |
137 // If you don't know about this effort, please read: | 138 // If you don't know about this effort, please read: |
138 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/pro file-architecture | 139 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/pro file-architecture |
139 // | 140 // |
140 // REVIEWERS: Do not let anyone increment this. We need to drive the number of | 141 // REVIEWERS: Do not let anyone increment this. We need to drive the number of |
141 // raw accessed services down to zero. DO NOT LET PEOPLE REGRESS THIS UNLESS | 142 // raw accessed services down to zero. DO NOT LET PEOPLE REGRESS THIS UNLESS |
142 // THE PATCH ITSELF IS MAKING PROGRESS ON PKSF REFACTORING. | 143 // THE PATCH ITSELF IS MAKING PROGRESS ON PKSF REFACTORING. |
143 COMPILE_ASSERT(sizeof(ProfileImpl) <= 744u, profile_impl_size_unexpected); | 144 COMPILE_ASSERT(sizeof(ProfileImpl) <= 744u, profile_impl_size_unexpected); |
sail
2013/03/26 17:25:02
Will your patch break this?
msarda
2013/03/26 17:33:26
Ninja compiled the code on my machine so I suppose
sail
2013/03/26 17:46:24
Maybe we don't support COMPILE_ASSERT on your plat
| |
144 #endif | 145 #endif |
145 | 146 |
146 #if defined(ENABLE_SESSION_SERVICE) | 147 #if defined(ENABLE_SESSION_SERVICE) |
147 // Delay, in milliseconds, before we explicitly create the SessionService. | 148 // Delay, in milliseconds, before we explicitly create the SessionService. |
148 static const int kCreateSessionServiceDelayMS = 500; | 149 static const int kCreateSessionServiceDelayMS = 500; |
149 #endif | 150 #endif |
150 | 151 |
151 // Text content of README file created in each profile directory. Both %s | 152 // Text content of README file created in each profile directory. Both %s |
152 // placeholders must contain the product name. This is not localizable and hence | 153 // placeholders must contain the product name. This is not localizable and hence |
153 // not in resources. | 154 // not in resources. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 path_(path), | 339 path_(path), |
339 pref_registry_(new PrefRegistrySyncable), | 340 pref_registry_(new PrefRegistrySyncable), |
340 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 341 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
341 host_content_settings_map_(NULL), | 342 host_content_settings_map_(NULL), |
342 last_session_exit_type_(EXIT_NORMAL), | 343 last_session_exit_type_(EXIT_NORMAL), |
343 start_time_(Time::Now()), | 344 start_time_(Time::Now()), |
344 delegate_(delegate), | 345 delegate_(delegate), |
345 predictor_(NULL) { | 346 predictor_(NULL) { |
346 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 347 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
347 "profile files to the root directory!"; | 348 "profile files to the root directory!"; |
348 | |
349 #if defined(ENABLE_SESSION_SERVICE) | 349 #if defined(ENABLE_SESSION_SERVICE) |
350 create_session_service_timer_.Start(FROM_HERE, | 350 create_session_service_timer_.Start(FROM_HERE, |
351 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 351 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
352 &ProfileImpl::EnsureSessionServiceCreated); | 352 &ProfileImpl::EnsureSessionServiceCreated); |
353 #endif | 353 #endif |
354 | 354 |
355 // Determine if prefetch is enabled for this profile. | 355 // Determine if prefetch is enabled for this profile. |
356 // If not profile_manager is present, it means we are in a unittest. | 356 // If not profile_manager is present, it means we are in a unittest. |
357 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 357 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
358 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 358 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 | 656 |
657 base::FilePath ProfileImpl::GetPath() { | 657 base::FilePath ProfileImpl::GetPath() { |
658 return path_; | 658 return path_; |
659 } | 659 } |
660 | 660 |
661 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { | 661 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { |
662 return JsonPrefStore::GetTaskRunnerForFile( | 662 return JsonPrefStore::GetTaskRunnerForFile( |
663 GetPath(), BrowserThread::GetBlockingPool()); | 663 GetPath(), BrowserThread::GetBlockingPool()); |
664 } | 664 } |
665 | 665 |
666 scoped_refptr<base::DeferredSequencedTaskRunner> | |
667 ProfileImpl::GetBookmarksTaskRunner() { | |
668 if (!bookmarks_task_runner_) { | |
669 bookmarks_task_runner_ = | |
670 new base::DeferredSequencedTaskRunner(GetIOTaskRunner()); | |
671 } | |
672 return bookmarks_task_runner_; | |
673 } | |
674 | |
666 bool ProfileImpl::IsOffTheRecord() const { | 675 bool ProfileImpl::IsOffTheRecord() const { |
667 return false; | 676 return false; |
668 } | 677 } |
669 | 678 |
670 Profile* ProfileImpl::GetOffTheRecordProfile() { | 679 Profile* ProfileImpl::GetOffTheRecordProfile() { |
671 if (!off_the_record_profile_.get()) { | 680 if (!off_the_record_profile_.get()) { |
672 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); | 681 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); |
673 off_the_record_profile_.swap(p); | 682 off_the_record_profile_.swap(p); |
674 | 683 |
675 content::NotificationService::current()->Notify( | 684 content::NotificationService::current()->Notify( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 base::FilePath* cache_path, | 1172 base::FilePath* cache_path, |
1164 int* max_size) { | 1173 int* max_size) { |
1165 DCHECK(cache_path); | 1174 DCHECK(cache_path); |
1166 DCHECK(max_size); | 1175 DCHECK(max_size); |
1167 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1176 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1168 if (!path.empty()) | 1177 if (!path.empty()) |
1169 *cache_path = path; | 1178 *cache_path = path; |
1170 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1179 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1171 prefs_->GetInteger(prefs::kDiskCacheSize); | 1180 prefs_->GetInteger(prefs::kDiskCacheSize); |
1172 } | 1181 } |
OLD | NEW |