Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/profile.cc

Issue 18630: Adds a command line switch to allow the user to specify the location... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | chrome/common/chrome_switches.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/profile.h" 5 #include "chrome/browser/profile.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/lock.h" 10 #include "base/lock.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 std::wstring pref_file_path = path_; 486 std::wstring pref_file_path = path_;
487 file_util::AppendToPath(&pref_file_path, chrome::kPreferencesFilename); 487 file_util::AppendToPath(&pref_file_path, chrome::kPreferencesFilename);
488 return pref_file_path; 488 return pref_file_path;
489 } 489 }
490 490
491 URLRequestContext* ProfileImpl::GetRequestContext() { 491 URLRequestContext* ProfileImpl::GetRequestContext() {
492 if (!request_context_) { 492 if (!request_context_) {
493 std::wstring cookie_path = GetPath(); 493 std::wstring cookie_path = GetPath();
494 file_util::AppendToPath(&cookie_path, chrome::kCookieFilename); 494 file_util::AppendToPath(&cookie_path, chrome::kCookieFilename);
495 std::wstring cache_path = GetPath(); 495 std::wstring cache_path = GetPath();
496
497 // Override the cache location if specified so
rvargas (doing something else) 2009/01/27 03:55:20 nit: Each comment has to be a complete sentence (a
498 const std::wstring user_cache_dir(
499 CommandLine::ForCurrentProcess()->GetSwitchValue(
rvargas (doing something else) 2009/01/27 03:55:20 nit: wrong indentation. See http://dev.chromium.or
500 switches::kDiskCacheLocation));
501 if (!user_cache_dir.empty()) {
502 // Create the directory if necessary. The browser needs it to
503 // exist to populate it.
504 if (file_util::DirectoryExists(user_cache_dir) ||
rvargas (doing something else) 2009/01/27 03:55:20 Remove all the code that creates the folder. That
505 file_util::CreateDirectory(user_cache_dir)) {
506 // This last check reflects the real need - we need a directory
507 // that we can add content to
508 if (file_util::PathIsWritable(user_cache_dir)) {
509 cache_path = user_cache_dir;
510 } else {
511 // Failing silently is the idea here, since this functionality is
512 // simply not important. If the user has specified an unusable
513 // path, the user can figure out how to make it work. If he cannot,
514 // he is probably not the kind of user who would care about moving
515 // the cache anyway. Command line options will eventually have
516 // to be documented somewhere, and then we can document the
517 // condition that the path must exist or its immediate parent
518 // must be writable.
519 }
520 }
521 }
522
496 file_util::AppendToPath(&cache_path, chrome::kCacheDirname); 523 file_util::AppendToPath(&cache_path, chrome::kCacheDirname);
497 request_context_ = ChromeURLRequestContext::CreateOriginal( 524 request_context_ = ChromeURLRequestContext::CreateOriginal(
498 this, cookie_path, cache_path); 525 this, cookie_path, cache_path);
499 request_context_->AddRef(); 526 request_context_->AddRef();
500 527
501 // The first request context is always a normal (non-OTR) request context. 528 // The first request context is always a normal (non-OTR) request context.
502 // Even when Chromium is started in OTR mode, a normal profile is always 529 // Even when Chromium is started in OTR mode, a normal profile is always
503 // created first. 530 // created first.
504 if (!default_request_context_) { 531 if (!default_request_context_) {
505 default_request_context_ = request_context_; 532 default_request_context_ = request_context_;
506 NotificationService::current()->Notify( 533 NotificationService::current()->Notify(
507 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE, 534 NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE,
508 NotificationService::AllSources(), NotificationService::NoDetails()); 535 NotificationService::AllSources(), NotificationService::NoDetails());
509 } 536 }
510 537
511 DCHECK(request_context_->cookie_store()); 538 DCHECK(request_context_->cookie_store());
512 } 539 }
513 540
rvargas (doing something else) 2009/01/27 03:55:20 nit: remove
541
514 return request_context_; 542 return request_context_;
515 } 543 }
516 544
517 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) { 545 HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) {
518 if (!history_service_created_) { 546 if (!history_service_created_) {
519 history_service_created_ = true; 547 history_service_created_ = true;
520 scoped_refptr<HistoryService> history(new HistoryService(this)); 548 scoped_refptr<HistoryService> history(new HistoryService(this));
521 if (!history->Init(GetPath(), GetBookmarkModel())) 549 if (!history->Init(GetPath(), GetBookmarkModel()))
522 return NULL; 550 return NULL;
523 history_service_.swap(history); 551 history_service_.swap(history);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 786 }
759 787
760 #ifdef CHROME_PERSONALIZATION 788 #ifdef CHROME_PERSONALIZATION
761 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { 789 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() {
762 if (!personalization_.get()) 790 if (!personalization_.get())
763 personalization_.reset( 791 personalization_.reset(
764 Personalization::CreateProfilePersonalization(this)); 792 Personalization::CreateProfilePersonalization(this));
765 return personalization_.get(); 793 return personalization_.get();
766 } 794 }
767 #endif 795 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | chrome/common/chrome_switches.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698