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

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 scafolding.
19 class AnyThreadNonTaskRunner : public base::SingleThreadTaskRunner {
20 public:
21 virtual bool RunsTasksOnCurrentThread() const OVERRIDE {
awong 2012/09/14 19:59:34 nit: indentation.
michaeln 2012/09/15 00:30:43 Done.
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
41 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
42 public:
43 TestContextURLRequestContextGetter(net::URLRequestContext* context)
44 : context_(context),
45 any_thread_non_task_runner_(new AnyThreadNonTaskRunner) {
46 }
47
48 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
49 return context_;
50 }
51
52 virtual scoped_refptr<base::SingleThreadTaskRunner>
53 GetNetworkTaskRunner() const OVERRIDE {
54 return any_thread_non_task_runner_;
55 }
56
57 protected:
58 virtual ~TestContextURLRequestContextGetter() {}
59
60 private:
61 net::URLRequestContext* context_;
62 scoped_refptr<base::SingleThreadTaskRunner> any_thread_non_task_runner_;
63 };
64
65 }
66
13 namespace content { 67 namespace content {
14 68
15 TestBrowserContext::TestBrowserContext() { 69 TestBrowserContext::TestBrowserContext() {
16 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir()); 70 EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
17 } 71 }
18 72
19 TestBrowserContext::~TestBrowserContext() { 73 TestBrowserContext::~TestBrowserContext() {
20 } 74 }
21 75
22 FilePath TestBrowserContext::TakePath() { 76 FilePath TestBrowserContext::TakePath() {
(...skipping 11 matching lines...) Expand all
34 88
35 bool TestBrowserContext::IsOffTheRecord() const { 89 bool TestBrowserContext::IsOffTheRecord() const {
36 return false; 90 return false;
37 } 91 }
38 92
39 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() { 93 DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
40 return NULL; 94 return NULL;
41 } 95 }
42 96
43 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() { 97 net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
44 return NULL; 98 return new TestContextURLRequestContextGetter(
99 GetResourceContext()->GetRequestContext());
45 } 100 }
46 101
47 net::URLRequestContextGetter* 102 net::URLRequestContextGetter*
48 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) { 103 TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
49 return NULL; 104 return NULL;
50 } 105 }
51 106
107
108 net::URLRequestContextGetter*
109 TestBrowserContext::GetRequestContextForStoragePartition(
110 const std::string& partition_id) {
111 return NULL;
112 }
113
52 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() { 114 net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
53 return NULL; 115 return NULL;
54 } 116 }
55 117
56 net::URLRequestContextGetter* 118 net::URLRequestContextGetter*
57 TestBrowserContext::GetMediaRequestContextForRenderProcess( 119 TestBrowserContext::GetMediaRequestContextForRenderProcess(
58 int renderer_child_id) { 120 int renderer_child_id) {
59 return NULL; 121 return NULL;
60 } 122 }
61 123
(...skipping 15 matching lines...) Expand all
77 139
78 bool TestBrowserContext::DidLastSessionExitCleanly() { 140 bool TestBrowserContext::DidLastSessionExitCleanly() {
79 return true; 141 return true;
80 } 142 }
81 143
82 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() { 144 quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
83 return special_storage_policy_.get(); 145 return special_storage_policy_.get();
84 } 146 }
85 147
86 } // namespace content 148 } // 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