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

Side by Side Diff: content/public/test/test_browser_context.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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 | « content/public/test/mock_resource_context.cc ('k') | content/test/webrtc_audio_device_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/test/test_browser_context.h" 5 #include "content/public/test/test_browser_context.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/test/null_task_runner.h" 8 #include "base/test/null_task_runner.h"
9 #include "content/public/test/mock_resource_context.h" 9 #include "content/public/test/mock_resource_context.h"
10 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
11 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
12 #include "net/url_request/url_request_test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "webkit/browser/quota/special_storage_policy.h" 14 #include "webkit/browser/quota/special_storage_policy.h"
14 15
15 namespace { 16 namespace {
16 17
17 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter { 18 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
18 public: 19 public:
19 explicit TestContextURLRequestContextGetter(net::URLRequestContext* context) 20 TestContextURLRequestContextGetter()
20 : context_(context), 21 : null_task_runner_(new base::NullTaskRunner) {
21 null_task_runner_(new base::NullTaskRunner) {
22 } 22 }
23 23
24 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { 24 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
25 return context_; 25 return &context_;
26 } 26 }
27 27
28 virtual scoped_refptr<base::SingleThreadTaskRunner> 28 virtual scoped_refptr<base::SingleThreadTaskRunner>
29 GetNetworkTaskRunner() const OVERRIDE { 29 GetNetworkTaskRunner() const OVERRIDE {
30 return null_task_runner_; 30 return null_task_runner_;
31 } 31 }
32 32
33 private: 33 private:
34 virtual ~TestContextURLRequestContextGetter() {} 34 virtual ~TestContextURLRequestContextGetter() {}
35 35
36 net::URLRequestContext* context_; 36 net::TestURLRequestContext context_;
37 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_; 37 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_;
38 }; 38 };
39 39
40 } // namespace 40 } // namespace
41 41
42 namespace content { 42 namespace content {
43 43
44 TestBrowserContext::TestBrowserContext() { 44 TestBrowserContext::TestBrowserContext() {
45 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir()); 45 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
46 } 46 }
(...skipping 17 matching lines...) Expand all
64 bool TestBrowserContext::IsOffTheRecord() const { 64 bool TestBrowserContext::IsOffTheRecord() const {
65 return false; 65 return false;
66 } 66 }
67 67
68 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() { 68 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
69 return NULL; 69 return NULL;
70 } 70 }
71 71
72 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() { 72 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
73 if (!request_context_.get()) { 73 if (!request_context_.get()) {
74 request_context_ = new TestContextURLRequestContextGetter( 74 request_context_ = new TestContextURLRequestContextGetter();
75 GetResourceContext()->GetRequestContext());
76 } 75 }
77 return request_context_.get(); 76 return request_context_.get();
78 } 77 }
79 78
80 net::URLRequestContextGetter* 79 net::URLRequestContextGetter*
81 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { 80 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
82 return NULL; 81 return NULL;
83 } 82 }
84 83
85 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() { 84 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
(...skipping 17 matching lines...) Expand all
103 int render_process_id, 102 int render_process_id,
104 int render_view_id, 103 int render_view_id,
105 const GURL& requesting_frame, 104 const GURL& requesting_frame,
106 const MIDISysExPermissionCallback& callback) { 105 const MIDISysExPermissionCallback& callback) {
107 // Always reject requests for testing. 106 // Always reject requests for testing.
108 callback.Run(false); 107 callback.Run(false);
109 } 108 }
110 109
111 ResourceContext* TestBrowserContext::GetResourceContext() { 110 ResourceContext* TestBrowserContext::GetResourceContext() {
112 if (!resource_context_) 111 if (!resource_context_)
113 resource_context_.reset(new MockResourceContext()); 112 resource_context_.reset(new MockResourceContext(
113 GetRequestContext()->GetURLRequestContext()));
114 return resource_context_.get(); 114 return resource_context_.get();
115 } 115 }
116 116
117 GeolocationPermissionContext* 117 GeolocationPermissionContext*
118 TestBrowserContext::GetGeolocationPermissionContext() { 118 TestBrowserContext::GetGeolocationPermissionContext() {
119 return NULL; 119 return NULL;
120 } 120 }
121 121
122 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { 122 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
123 return special_storage_policy_.get(); 123 return special_storage_policy_.get();
124 } 124 }
125 125
126 } // namespace content 126 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/mock_resource_context.cc ('k') | content/test/webrtc_audio_device_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698