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

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

Issue 10916132: AppCache and StoragePartition'ing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/test_browser_context.h ('k') | content/shell/shell_browser_context.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/file_path.h" 7 #include "base/file_path.h"
8 #include "content/public/test/mock_resource_context.h" 8 #include "content/public/test/mock_resource_context.h"
9 #include "net/url_request/url_request_context.h" 9 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_getter.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/quota/special_storage_policy.h" 12 #include "webkit/quota/special_storage_policy.h"
12 13
14 namespace {
15
16 // A silly class to satisfy net::URLRequestsContextGetter requirement
17 // for a task runner. Threading requirements don't matter for this
18 // test scaffolding.
19 class AnyThreadNonTaskRunner : public base::SingleThreadTaskRunner {
20 public:
21 virtual bool RunsTasksOnCurrentThread() const OVERRIDE {
22 return true;
23 }
24
25 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
26 const base::Closure& task,
27 base::TimeDelta delay) OVERRIDE {
28 NOTREACHED();
29 return false;
30 }
31
32 virtual bool PostNonNestableDelayedTask(
33 const tracked_objects::Location& from_here,
34 const base::Closure& task,
35 base::TimeDelta delay) OVERRIDE {
36 NOTREACHED();
37 return false;
38 }
39
40 private:
41 virtual ~AnyThreadNonTaskRunner() {}
42 };
43
44 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
45 public:
46 TestContextURLRequestContextGetter(net::URLRequestContext* context)
47 : context_(context),
48 any_thread_non_task_runner_(new AnyThreadNonTaskRunner) {
49 }
50
51 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
52 return context_;
53 }
54
55 virtual scoped_refptr<base::SingleThreadTaskRunner>
56 GetNetworkTaskRunner() const OVERRIDE {
57 return any_thread_non_task_runner_;
58 }
59
60 private:
61 virtual ~TestContextURLRequestContextGetter() {}
62
63 net::URLRequestContext* context_;
64 scoped_refptr<base::SingleThreadTaskRunner> any_thread_non_task_runner_;
65 };
66
67 }
68
13 namespace content { 69 namespace content {
14 70
15 TestBrowserContext::TestBrowserContext() { 71 TestBrowserContext::TestBrowserContext() {
16 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir()); 72 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
17 } 73 }
18 74
19 TestBrowserContext::~TestBrowserContext() { 75 TestBrowserContext::~TestBrowserContext() {
20 } 76 }
21 77
22 FilePath TestBrowserContext::TakePath() { 78 FilePath TestBrowserContext::TakePath() {
(...skipping 11 matching lines...) Expand all
34 90
35 bool TestBrowserContext::IsOffTheRecord() const { 91 bool TestBrowserContext::IsOffTheRecord() const {
36 return false; 92 return false;
37 } 93 }
38 94
39 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() { 95 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
40 return NULL; 96 return NULL;
41 } 97 }
42 98
43 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() { 99 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
44 return NULL; 100 return new TestContextURLRequestContextGetter(
101 GetResourceContext()->GetRequestContext());
45 } 102 }
46 103
47 net::URLRequestContextGetter* 104 net::URLRequestContextGetter*
48 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { 105 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
49 return NULL; 106 return NULL;
50 } 107 }
51 108
109
110 net::URLRequestContextGetter*
111 TestBrowserContext::GetRequestContextForStoragePartition(
112 const std::string& partition_id) {
113 return NULL;
114 }
115
52 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() { 116 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
53 return NULL; 117 return NULL;
54 } 118 }
55 119
56 net::URLRequestContextGetter* 120 net::URLRequestContextGetter*
57 TestBrowserContext::GetMediaRequestContextForRenderProcess( 121 TestBrowserContext::GetMediaRequestContextForRenderProcess(
58 int renderer_child_id) { 122 int renderer_child_id) {
59 return NULL; 123 return NULL;
60 } 124 }
61 125
(...skipping 15 matching lines...) Expand all
77 141
78 bool TestBrowserContext::DidLastSessionExitCleanly() { 142 bool TestBrowserContext::DidLastSessionExitCleanly() {
79 return true; 143 return true;
80 } 144 }
81 145
82 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { 146 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
83 return special_storage_policy_.get(); 147 return special_storage_policy_.get();
84 } 148 }
85 149
86 } // namespace content 150 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_browser_context.h ('k') | content/shell/shell_browser_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698