1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/web/public/test/test_browser_state.h"
7 #include "base/files/file_path.h"
8 #include "base/test/null_task_runner.h"
9 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_getter.h"
11 #include "net/url_request/url_request_test_util.h"
15 class TestContextURLRequestContextGetter
: public net::URLRequestContextGetter
{
17 TestContextURLRequestContextGetter()
18 : null_task_runner_(new base::NullTaskRunner
) {}
20 net::URLRequestContext
* GetURLRequestContext() override
{ return &context_
; }
22 scoped_refptr
<base::SingleThreadTaskRunner
>
23 GetNetworkTaskRunner() const override
{
24 return null_task_runner_
;
28 ~TestContextURLRequestContextGetter() override
{}
30 net::TestURLRequestContext context_
;
31 scoped_refptr
<base::SingleThreadTaskRunner
> null_task_runner_
;
37 TestBrowserState::TestBrowserState() {
40 TestBrowserState::~TestBrowserState() {
43 bool TestBrowserState::IsOffTheRecord() const {
47 base::FilePath
TestBrowserState::GetStatePath() const {
48 return base::FilePath();
51 net::URLRequestContextGetter
* TestBrowserState::GetRequestContext() {
52 if (!request_context_
)
53 request_context_
= new TestContextURLRequestContextGetter();
54 return request_context_
.get();