PERF SHERIFF: This CL changes the tough_energy_cases test.
[chromium-blink-merge.git] / content / public / test / test_browser_context.cc
blob3c80a02a812ab759240f9e7741c4baef61000831
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
3 // found in the LICENSE file.
5 #include "content/public/test/test_browser_context.h"
7 #include "base/files/file_path.h"
8 #include "base/test/null_task_runner.h"
9 #include "content/public/test/mock_resource_context.h"
10 #include "net/url_request/url_request_context.h"
11 #include "net/url_request/url_request_context_getter.h"
12 #include "net/url_request/url_request_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webkit/browser/quota/special_storage_policy.h"
16 namespace {
18 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
19 public:
20 TestContextURLRequestContextGetter()
21 : null_task_runner_(new base::NullTaskRunner) {
24 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
25 return &context_;
28 virtual scoped_refptr<base::SingleThreadTaskRunner>
29 GetNetworkTaskRunner() const OVERRIDE {
30 return null_task_runner_;
33 private:
34 virtual ~TestContextURLRequestContextGetter() {}
36 net::TestURLRequestContext context_;
37 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_;
40 } // namespace
42 namespace content {
44 TestBrowserContext::TestBrowserContext() {
45 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
48 TestBrowserContext::~TestBrowserContext() {
51 base::FilePath TestBrowserContext::TakePath() {
52 return browser_context_dir_.Take();
55 void TestBrowserContext::SetSpecialStoragePolicy(
56 storage::SpecialStoragePolicy* policy) {
57 special_storage_policy_ = policy;
60 base::FilePath TestBrowserContext::GetPath() const {
61 return browser_context_dir_.path();
64 bool TestBrowserContext::IsOffTheRecord() const {
65 return false;
68 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
69 return NULL;
72 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
73 if (!request_context_.get()) {
74 request_context_ = new TestContextURLRequestContextGetter();
76 return request_context_.get();
79 net::URLRequestContextGetter*
80 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
81 return NULL;
84 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
85 return NULL;
88 net::URLRequestContextGetter*
89 TestBrowserContext::GetMediaRequestContextForRenderProcess(
90 int renderer_child_id) {
91 return NULL;
94 net::URLRequestContextGetter*
95 TestBrowserContext::GetMediaRequestContextForStoragePartition(
96 const base::FilePath& partition_path,
97 bool in_memory) {
98 return NULL;
101 ResourceContext* TestBrowserContext::GetResourceContext() {
102 if (!resource_context_)
103 resource_context_.reset(new MockResourceContext(
104 GetRequestContext()->GetURLRequestContext()));
105 return resource_context_.get();
108 BrowserPluginGuestManager* TestBrowserContext::GetGuestManager() {
109 return NULL;
112 storage::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
113 return special_storage_policy_.get();
116 PushMessagingService* TestBrowserContext::GetPushMessagingService() {
117 return NULL;
120 SSLHostStateDelegate* TestBrowserContext::GetSSLHostStateDelegate() {
121 return NULL;
124 } // namespace content