OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/testing_profile.h" | 5 #include "chrome/test/testing_profile.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // a leak if your test does not have a ChromeThread::IO in it because | 101 // a leak if your test does not have a ChromeThread::IO in it because |
102 // URLRequestContextGetter is defined as a ReferenceCounted object with a | 102 // URLRequestContextGetter is defined as a ReferenceCounted object with a |
103 // special trait that deletes it on the IO thread. | 103 // special trait that deletes it on the IO thread. |
104 class TestURLRequestContextGetter : public URLRequestContextGetter { | 104 class TestURLRequestContextGetter : public URLRequestContextGetter { |
105 public: | 105 public: |
106 virtual URLRequestContext* GetURLRequestContext() { | 106 virtual URLRequestContext* GetURLRequestContext() { |
107 if (!context_) | 107 if (!context_) |
108 context_ = new TestURLRequestContext(); | 108 context_ = new TestURLRequestContext(); |
109 return context_.get(); | 109 return context_.get(); |
110 } | 110 } |
111 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() { | 111 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { |
112 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); | 112 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); |
113 } | 113 } |
114 | 114 |
115 private: | 115 private: |
116 scoped_refptr<URLRequestContext> context_; | 116 scoped_refptr<URLRequestContext> context_; |
117 }; | 117 }; |
118 | 118 |
119 class TestExtensionURLRequestContext : public URLRequestContext { | 119 class TestExtensionURLRequestContext : public URLRequestContext { |
120 public: | 120 public: |
121 TestExtensionURLRequestContext() { | 121 TestExtensionURLRequestContext() { |
122 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); | 122 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); |
123 const char* schemes[] = {chrome::kExtensionScheme}; | 123 const char* schemes[] = {chrome::kExtensionScheme}; |
124 cookie_monster->SetCookieableSchemes(schemes, 1); | 124 cookie_monster->SetCookieableSchemes(schemes, 1); |
125 cookie_store_ = cookie_monster; | 125 cookie_store_ = cookie_monster; |
126 } | 126 } |
127 }; | 127 }; |
128 | 128 |
129 class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { | 129 class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { |
130 public: | 130 public: |
131 virtual URLRequestContext* GetURLRequestContext() { | 131 virtual URLRequestContext* GetURLRequestContext() { |
132 if (!context_) | 132 if (!context_) |
133 context_ = new TestExtensionURLRequestContext(); | 133 context_ = new TestExtensionURLRequestContext(); |
134 return context_.get(); | 134 return context_.get(); |
135 } | 135 } |
136 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() { | 136 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { |
137 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); | 137 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); |
138 } | 138 } |
139 | 139 |
140 private: | 140 private: |
141 scoped_refptr<URLRequestContext> context_; | 141 scoped_refptr<URLRequestContext> context_; |
142 }; | 142 }; |
143 | 143 |
144 } // namespace | 144 } // namespace |
145 | 145 |
146 TestingProfile::TestingProfile() | 146 TestingProfile::TestingProfile() |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 348 } |
349 return profile_sync_service_.get(); | 349 return profile_sync_service_.get(); |
350 } | 350 } |
351 | 351 |
352 void TestingProfile::DestroyWebDataService() { | 352 void TestingProfile::DestroyWebDataService() { |
353 if (!web_data_service_.get()) | 353 if (!web_data_service_.get()) |
354 return; | 354 return; |
355 | 355 |
356 web_data_service_->Shutdown(); | 356 web_data_service_->Shutdown(); |
357 } | 357 } |
OLD | NEW |