| 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 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // a leak if your test does not have a BrowserThread::IO in it because | 115 // a leak if your test does not have a BrowserThread::IO in it because |
| 116 // URLRequestContextGetter is defined as a ReferenceCounted object with a | 116 // URLRequestContextGetter is defined as a ReferenceCounted object with a |
| 117 // special trait that deletes it on the IO thread. | 117 // special trait that deletes it on the IO thread. |
| 118 class TestURLRequestContextGetter : public URLRequestContextGetter { | 118 class TestURLRequestContextGetter : public URLRequestContextGetter { |
| 119 public: | 119 public: |
| 120 virtual URLRequestContext* GetURLRequestContext() { | 120 virtual URLRequestContext* GetURLRequestContext() { |
| 121 if (!context_) | 121 if (!context_) |
| 122 context_ = new TestURLRequestContext(); | 122 context_ = new TestURLRequestContext(); |
| 123 return context_.get(); | 123 return context_.get(); |
| 124 } | 124 } |
| 125 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { | 125 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
| 126 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 126 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 scoped_refptr<URLRequestContext> context_; | 130 scoped_refptr<URLRequestContext> context_; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 class TestExtensionURLRequestContext : public URLRequestContext { | 133 class TestExtensionURLRequestContext : public URLRequestContext { |
| 134 public: | 134 public: |
| 135 TestExtensionURLRequestContext() { | 135 TestExtensionURLRequestContext() { |
| 136 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); | 136 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); |
| 137 const char* schemes[] = {chrome::kExtensionScheme}; | 137 const char* schemes[] = {chrome::kExtensionScheme}; |
| 138 cookie_monster->SetCookieableSchemes(schemes, 1); | 138 cookie_monster->SetCookieableSchemes(schemes, 1); |
| 139 cookie_store_ = cookie_monster; | 139 cookie_store_ = cookie_monster; |
| 140 } | 140 } |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { | 143 class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { |
| 144 public: | 144 public: |
| 145 virtual URLRequestContext* GetURLRequestContext() { | 145 virtual URLRequestContext* GetURLRequestContext() { |
| 146 if (!context_) | 146 if (!context_) |
| 147 context_ = new TestExtensionURLRequestContext(); | 147 context_ = new TestExtensionURLRequestContext(); |
| 148 return context_.get(); | 148 return context_.get(); |
| 149 } | 149 } |
| 150 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { | 150 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
| 151 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 151 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 152 } | 152 } |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 scoped_refptr<URLRequestContext> context_; | 155 scoped_refptr<URLRequestContext> context_; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace | 158 } // namespace |
| 159 | 159 |
| 160 TestingProfile::TestingProfile() | 160 TestingProfile::TestingProfile() |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 505 } |
| 506 return profile_sync_service_.get(); | 506 return profile_sync_service_.get(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void TestingProfile::DestroyWebDataService() { | 509 void TestingProfile::DestroyWebDataService() { |
| 510 if (!web_data_service_.get()) | 510 if (!web_data_service_.get()) |
| 511 return; | 511 return; |
| 512 | 512 |
| 513 web_data_service_->Shutdown(); | 513 web_data_service_->Shutdown(); |
| 514 } | 514 } |
| OLD | NEW |