Chromium Code Reviews| Index: chrome/test/test_url_request_context_getter.h |
| diff --git a/chrome/test/test_url_request_context_getter.h b/chrome/test/test_url_request_context_getter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8ac7b05527e1577fb4ab5b63ceb7488af8ce7808 |
| --- /dev/null |
| +++ b/chrome/test/test_url_request_context_getter.h |
| @@ -0,0 +1,33 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_TEST_TEST_URL_REQUEST_CONTEXT_GETTER_H_ |
| +#define CHROME_TEST_TEST_URL_REQUEST_CONTEXT_GETTER_H_ |
| + |
| +#include "base/ref_counted.h" |
| +#include "chrome/browser/browser_thread.h" |
| +#include "chrome/common/net/url_request_context_getter.h" |
| +#include "net/url_request/url_request_unittest.h" |
| + |
| +// Used to return a dummy context (normally the context is on the IO thread). |
| +// The one here can be run on the main test thread. Note that this can lead to |
| +// a leak if your test does not have a BrowserThread::IO in it because |
| +// URLRequestContextGetter is defined as a ReferenceCounted object with a |
| +// special trait that deletes it on the IO thread. |
| +class TestURLRequestContextGetter : public URLRequestContextGetter { |
| + public: |
| + virtual URLRequestContext* GetURLRequestContext() { |
| + if (!context_) |
| + context_ = new TestURLRequestContext(); |
| + return context_.get(); |
| + } |
| + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
| + return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
|
Nico
2010/11/22 11:06:06
why is this override needed?
Mattias Nissler (ping if slow)
2010/11/22 12:35:39
Ignored :)
|
| + } |
| + |
| + private: |
| + scoped_refptr<URLRequestContext> context_; |
| +}; |
| + |
| +#endif // CHROME_TEST_TEST_URL_REQUEST_CONTEXT_GETTER_H_ |