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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 11147026: Initial refactor to get profiles to propagate storage partition details. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed macro and InMemory. Created 8 years, 2 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
OLDNEW
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/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/history/shortcuts_backend_factory.h" 33 #include "chrome/browser/history/shortcuts_backend_factory.h"
34 #include "chrome/browser/history/top_sites.h" 34 #include "chrome/browser/history/top_sites.h"
35 #include "chrome/browser/net/proxy_service_factory.h" 35 #include "chrome/browser/net/proxy_service_factory.h"
36 #include "chrome/browser/notifications/desktop_notification_service.h" 36 #include "chrome/browser/notifications/desktop_notification_service.h"
37 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 37 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
38 #include "chrome/browser/policy/user_cloud_policy_manager.h" 38 #include "chrome/browser/policy/user_cloud_policy_manager.h"
39 #include "chrome/browser/prefs/browser_prefs.h" 39 #include "chrome/browser/prefs/browser_prefs.h"
40 #include "chrome/browser/prefs/testing_pref_store.h" 40 #include "chrome/browser/prefs/testing_pref_store.h"
41 #include "chrome/browser/prerender/prerender_manager.h" 41 #include "chrome/browser/prerender/prerender_manager.h"
42 #include "chrome/browser/profiles/profile_dependency_manager.h" 42 #include "chrome/browser/profiles/profile_dependency_manager.h"
43 #include "chrome/browser/profiles/storage_partition_descriptor.h"
43 #include "chrome/browser/protector/protector_service_factory.h" 44 #include "chrome/browser/protector/protector_service_factory.h"
44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
45 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" 46 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
46 #include "chrome/browser/webdata/web_data_service.h" 47 #include "chrome/browser/webdata/web_data_service.h"
47 #include "chrome/browser/webdata/web_data_service_factory.h" 48 #include "chrome/browser/webdata/web_data_service_factory.h"
48 #include "chrome/common/chrome_constants.h" 49 #include "chrome/common/chrome_constants.h"
49 #include "chrome/common/chrome_notification_types.h" 50 #include "chrome/common/chrome_notification_types.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
52 #include "chrome/test/base/bookmark_load_observer.h" 53 #include "chrome/test/base/bookmark_load_observer.h"
53 #include "chrome/test/base/history_index_restore_observer.h" 54 #include "chrome/test/base/history_index_restore_observer.h"
54 #include "chrome/test/base/testing_pref_service.h" 55 #include "chrome/test/base/testing_pref_service.h"
55 #include "chrome/test/base/ui_test_utils.h" 56 #include "chrome/test/base/ui_test_utils.h"
56 #include "content/public/browser/browser_thread.h" 57 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/notification_service.h" 58 #include "content/public/browser/notification_service.h"
59 #include "content/public/browser/storage_partition.h"
58 #include "content/public/browser/render_process_host.h" 60 #include "content/public/browser/render_process_host.h"
59 #include "content/public/test/mock_resource_context.h" 61 #include "content/public/test/mock_resource_context.h"
60 #include "content/public/test/test_utils.h" 62 #include "content/public/test/test_utils.h"
61 #include "net/cookies/cookie_monster.h" 63 #include "net/cookies/cookie_monster.h"
62 #include "net/url_request/url_request_context.h" 64 #include "net/url_request/url_request_context.h"
63 #include "net/url_request/url_request_context_getter.h" 65 #include "net/url_request/url_request_context_getter.h"
64 #include "net/url_request/url_request_test_util.h" 66 #include "net/url_request/url_request_test_util.h"
65 #include "testing/gmock/include/gmock/gmock.h" 67 #include "testing/gmock/include/gmock/gmock.h"
66 68
67 #if defined(ENABLE_CONFIGURATION_POLICY) 69 #if defined(ENABLE_CONFIGURATION_POLICY)
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { 615 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
614 return NULL; 616 return NULL;
615 } 617 }
616 618
617 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 619 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
618 return request_context_.get(); 620 return request_context_.get();
619 } 621 }
620 622
621 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( 623 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess(
622 int renderer_child_id) { 624 int renderer_child_id) {
623 ExtensionService* extension_service = 625 content::RenderProcessHost* rph = content::RenderProcessHost::FromID(
624 extensions::ExtensionSystem::Get(this)->extension_service(); 626 renderer_child_id);
625 if (extension_service) { 627 CHECK(rph);
awong 2012/10/19 23:26:50 remove CHECK()
nasko 2012/10/19 23:55:16 Done.
626 const extensions::Extension* extension = 628 content::StoragePartition* storage_partition = rph->GetStoragePartition();
627 extension_service->GetIsolatedAppForRenderer(renderer_child_id); 629
628 if (extension) 630 // TODO(nasko): Remove this conditional, once browser tag creates a proper
629 return GetRequestContextForStoragePartition(extension->id()); 631 // storage partition.
632 if (rph->IsGuest()) {
633 return GetRequestContextForStoragePartition(
634 storage_partition->GetPath(), true);
630 } 635 }
631 636
632 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( 637 return storage_partition->GetURLRequestContext();
633 renderer_child_id);
634 if (rph && rph->IsGuest()) {
635 // For guest processes (used by the browser tag), we need to isolate the
636 // storage.
637 // TODO(nasko): Until we have proper storage partitions, create a
638 // non-persistent context using the RPH's id.
639 std::string id("guest-");
640 id.append(base::IntToString(renderer_child_id));
641 return GetRequestContextForStoragePartition(id);
642 }
643
644 return GetRequestContext();
645 } 638 }
646 639
647 void TestingProfile::CreateRequestContext() { 640 void TestingProfile::CreateRequestContext() {
648 if (!request_context_) 641 if (!request_context_)
649 request_context_ = 642 request_context_ =
650 new TestURLRequestContextGetter( 643 new TestURLRequestContextGetter(
651 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 644 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
652 } 645 }
653 646
654 void TestingProfile::ResetRequestContext() { 647 void TestingProfile::ResetRequestContext() {
655 // Any objects holding live URLFetchers should be deleted before the request 648 // Any objects holding live URLFetchers should be deleted before the request
656 // context is shut down. 649 // context is shut down.
657 TemplateURLFetcherFactory::ShutdownForProfile(this); 650 TemplateURLFetcherFactory::ShutdownForProfile(this);
658 651
659 request_context_ = NULL; 652 request_context_ = NULL;
660 } 653 }
661 654
662 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { 655 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() {
663 return NULL; 656 return NULL;
664 } 657 }
665 658
666 net::URLRequestContextGetter* 659 net::URLRequestContextGetter*
667 TestingProfile::GetMediaRequestContextForRenderProcess( 660 TestingProfile::GetMediaRequestContextForRenderProcess(
668 int renderer_child_id) { 661 int renderer_child_id) {
669 return NULL; 662 return NULL;
670 } 663 }
671 664
672 net::URLRequestContextGetter* 665 net::URLRequestContextGetter*
673 TestingProfile::GetMediaRequestContextForStoragePartition( 666 TestingProfile::GetMediaRequestContextForStoragePartition(
674 const std::string& partition_id) { 667 const FilePath& partition_path,
668 bool in_memory) {
675 return NULL; 669 return NULL;
676 } 670 }
677 671
678 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { 672 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
679 if (!extensions_request_context_) 673 if (!extensions_request_context_)
680 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); 674 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
681 return extensions_request_context_.get(); 675 return extensions_request_context_.get();
682 } 676 }
683 677
684 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 678 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
685 return NULL; 679 return NULL;
686 } 680 }
687 681
688 net::URLRequestContextGetter* 682 net::URLRequestContextGetter*
689 TestingProfile::GetRequestContextForStoragePartition( 683 TestingProfile::GetRequestContextForStoragePartition(
690 const std::string& partition_id) { 684 const FilePath& partition_path,
685 bool in_memory) {
691 // We don't test storage partitions here yet, so returning the same dummy 686 // We don't test storage partitions here yet, so returning the same dummy
692 // context is sufficient for now. 687 // context is sufficient for now.
693 return GetRequestContext(); 688 return GetRequestContext();
694 } 689 }
695 690
696 content::ResourceContext* TestingProfile::GetResourceContext() { 691 content::ResourceContext* TestingProfile::GetResourceContext() {
697 if (!resource_context_.get()) 692 if (!resource_context_.get())
698 resource_context_.reset(new content::MockResourceContext()); 693 resource_context_.reset(new content::MockResourceContext());
699 return resource_context_.get(); 694 return resource_context_.get();
700 } 695 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 841 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
847 DCHECK(!build_called_); 842 DCHECK(!build_called_);
848 build_called_ = true; 843 build_called_ = true;
849 return scoped_ptr<TestingProfile>(new TestingProfile( 844 return scoped_ptr<TestingProfile>(new TestingProfile(
850 path_, 845 path_,
851 delegate_, 846 delegate_,
852 extension_policy_, 847 extension_policy_,
853 pref_service_.Pass(), 848 pref_service_.Pass(),
854 user_cloud_policy_manager_.Pass())); 849 user_cloud_policy_manager_.Pass()));
855 } 850 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698