OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/browser_side_navigation_test_utils.h" | 5 #include "content/public/test/browser_side_navigation_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "content/browser/streams/stream.h" | 11 #include "content/browser/streams/stream.h" |
12 #include "content/browser/streams/stream_registry.h" | 12 #include "content/browser/streams/stream_registry.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/stream_handle.h" | 14 #include "content/public/browser/stream_handle.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "content/test/test_navigation_url_loader_factory.h" | 16 #include "content/test/test_navigation_url_loader_factory.h" |
| 17 #include "net/base/net_errors.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // PlzNavigate | 23 // PlzNavigate |
23 // A UI thread singleton helper class for browser side navigations. When browser | 24 // A UI thread singleton helper class for browser side navigations. When browser |
24 // side navigations are enabled, initialize this class before doing any | 25 // side navigations are enabled, initialize this class before doing any |
25 // operation that may start a navigation request on the UI thread. Use TearDown | 26 // operation that may start a navigation request on the UI thread. Use TearDown |
26 // at the end of the test. | 27 // at the end of the test. |
(...skipping 28 matching lines...) Expand all Loading... |
55 void BrowserSideNavigationTearDown() { | 56 void BrowserSideNavigationTearDown() { |
56 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 57 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
57 browser_side_navigation_test_utils.Get().reset(nullptr); | 58 browser_side_navigation_test_utils.Get().reset(nullptr); |
58 } | 59 } |
59 | 60 |
60 std::unique_ptr<StreamHandle> MakeEmptyStream() { | 61 std::unique_ptr<StreamHandle> MakeEmptyStream() { |
61 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); | 62 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); |
62 StreamRegistry* stream_registry = | 63 StreamRegistry* stream_registry = |
63 browser_side_navigation_test_utils.Get()->stream_registry(); | 64 browser_side_navigation_test_utils.Get()->stream_registry(); |
64 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); | 65 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); |
65 stream->Finalize(); | 66 stream->Finalize(net::OK); |
66 return stream->CreateHandle(); | 67 return stream->CreateHandle(); |
67 } | 68 } |
68 | 69 |
69 void EnableBrowserSideNavigation() { | 70 void EnableBrowserSideNavigation() { |
70 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 71 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
71 switches::kEnableBrowserSideNavigation); | 72 switches::kEnableBrowserSideNavigation); |
72 } | 73 } |
73 | 74 |
74 } // namespace content | 75 } // namespace content |
OLD | NEW |