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/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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 if (delegate_) | 322 if (delegate_) |
323 delegate_->OnProfileCreated(this, true, false); | 323 delegate_->OnProfileCreated(this, true, false); |
324 } | 324 } |
325 | 325 |
326 TestingProfile::~TestingProfile() { | 326 TestingProfile::~TestingProfile() { |
327 MaybeSendDestroyedNotification(); | 327 MaybeSendDestroyedNotification(); |
328 | 328 |
329 browser_context_dependency_manager_->DestroyBrowserContextServices(this); | 329 browser_context_dependency_manager_->DestroyBrowserContextServices(this); |
330 | 330 |
331 if (host_content_settings_map_) | 331 if (host_content_settings_map_.get()) |
332 host_content_settings_map_->ShutdownOnUIThread(); | 332 host_content_settings_map_->ShutdownOnUIThread(); |
333 | 333 |
334 DestroyTopSites(); | 334 DestroyTopSites(); |
335 | 335 |
336 if (pref_proxy_config_tracker_.get()) | 336 if (pref_proxy_config_tracker_.get()) |
337 pref_proxy_config_tracker_->DetachFromPrefService(); | 337 pref_proxy_config_tracker_->DetachFromPrefService(); |
338 } | 338 } |
339 | 339 |
340 static BrowserContextKeyedService* BuildFaviconService( | 340 static BrowserContextKeyedService* BuildFaviconService( |
341 content::BrowserContext* profile) { | 341 content::BrowserContext* profile) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 | 610 |
611 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( | 611 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( |
612 int renderer_child_id) { | 612 int renderer_child_id) { |
613 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( | 613 content::RenderProcessHost* rph = content::RenderProcessHost::FromID( |
614 renderer_child_id); | 614 renderer_child_id); |
615 return rph->GetStoragePartition()->GetURLRequestContext(); | 615 return rph->GetStoragePartition()->GetURLRequestContext(); |
616 } | 616 } |
617 | 617 |
618 void TestingProfile::CreateRequestContext() { | 618 void TestingProfile::CreateRequestContext() { |
619 if (!request_context_) | 619 if (!request_context_.get()) |
620 request_context_ = | 620 request_context_ = new net::TestURLRequestContextGetter( |
621 new net::TestURLRequestContextGetter( | 621 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
622 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
623 } | 622 } |
624 | 623 |
625 void TestingProfile::ResetRequestContext() { | 624 void TestingProfile::ResetRequestContext() { |
626 // Any objects holding live URLFetchers should be deleted before the request | 625 // Any objects holding live URLFetchers should be deleted before the request |
627 // context is shut down. | 626 // context is shut down. |
628 TemplateURLFetcherFactory::ShutdownForProfile(this); | 627 TemplateURLFetcherFactory::ShutdownForProfile(this); |
629 | 628 |
630 request_context_ = NULL; | 629 request_context_ = NULL; |
631 } | 630 } |
632 | 631 |
633 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { | 632 net::URLRequestContextGetter* TestingProfile::GetMediaRequestContext() { |
634 return NULL; | 633 return NULL; |
635 } | 634 } |
636 | 635 |
637 net::URLRequestContextGetter* | 636 net::URLRequestContextGetter* |
638 TestingProfile::GetMediaRequestContextForRenderProcess( | 637 TestingProfile::GetMediaRequestContextForRenderProcess( |
639 int renderer_child_id) { | 638 int renderer_child_id) { |
640 return NULL; | 639 return NULL; |
641 } | 640 } |
642 | 641 |
643 net::URLRequestContextGetter* | 642 net::URLRequestContextGetter* |
644 TestingProfile::GetMediaRequestContextForStoragePartition( | 643 TestingProfile::GetMediaRequestContextForStoragePartition( |
645 const base::FilePath& partition_path, | 644 const base::FilePath& partition_path, |
646 bool in_memory) { | 645 bool in_memory) { |
647 return NULL; | 646 return NULL; |
648 } | 647 } |
649 | 648 |
650 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { | 649 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { |
651 if (!extensions_request_context_) | 650 if (!extensions_request_context_.get()) |
652 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); | 651 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); |
653 return extensions_request_context_.get(); | 652 return extensions_request_context_.get(); |
654 } | 653 } |
655 | 654 |
656 net::SSLConfigService* TestingProfile::GetSSLConfigService() { | 655 net::SSLConfigService* TestingProfile::GetSSLConfigService() { |
657 if (!GetRequestContext()) | 656 if (!GetRequestContext()) |
658 return NULL; | 657 return NULL; |
659 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); | 658 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); |
660 } | 659 } |
661 | 660 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 807 |
809 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 808 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
810 DCHECK(!build_called_); | 809 DCHECK(!build_called_); |
811 build_called_ = true; | 810 build_called_ = true; |
812 return scoped_ptr<TestingProfile>(new TestingProfile( | 811 return scoped_ptr<TestingProfile>(new TestingProfile( |
813 path_, | 812 path_, |
814 delegate_, | 813 delegate_, |
815 extension_policy_, | 814 extension_policy_, |
816 pref_service_.Pass())); | 815 pref_service_.Pass())); |
817 } | 816 } |
OLD | NEW |