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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 ~BrowserSideNavigationTestUtils() {} | 35 ~BrowserSideNavigationTestUtils() {} |
36 StreamRegistry* stream_registry() { return stream_registry_.get();} | 36 StreamRegistry* stream_registry() { return stream_registry_.get();} |
37 | 37 |
38 private: | 38 private: |
39 std::unique_ptr<StreamRegistry> stream_registry_; | 39 std::unique_ptr<StreamRegistry> stream_registry_; |
40 std::unique_ptr<TestNavigationURLLoaderFactory> loader_factory_; | 40 std::unique_ptr<TestNavigationURLLoaderFactory> loader_factory_; |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(BrowserSideNavigationTestUtils); | 42 DISALLOW_COPY_AND_ASSIGN(BrowserSideNavigationTestUtils); |
43 }; | 43 }; |
44 | 44 |
45 base::LazyInstance<std::unique_ptr<BrowserSideNavigationTestUtils>> | 45 base::LazyInstance<std::unique_ptr<BrowserSideNavigationTestUtils>>:: |
46 browser_side_navigation_test_utils; | 46 DestructorAtExit browser_side_navigation_test_utils; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 void BrowserSideNavigationSetUp() { | 50 void BrowserSideNavigationSetUp() { |
51 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
52 browser_side_navigation_test_utils.Get().reset( | 52 browser_side_navigation_test_utils.Get().reset( |
53 new BrowserSideNavigationTestUtils); | 53 new BrowserSideNavigationTestUtils); |
54 } | 54 } |
55 | 55 |
56 void BrowserSideNavigationTearDown() { | 56 void BrowserSideNavigationTearDown() { |
57 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 57 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
58 browser_side_navigation_test_utils.Get().reset(nullptr); | 58 browser_side_navigation_test_utils.Get().reset(nullptr); |
59 } | 59 } |
60 | 60 |
61 std::unique_ptr<StreamHandle> MakeEmptyStream() { | 61 std::unique_ptr<StreamHandle> MakeEmptyStream() { |
62 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); | 62 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); |
63 StreamRegistry* stream_registry = | 63 StreamRegistry* stream_registry = |
64 browser_side_navigation_test_utils.Get()->stream_registry(); | 64 browser_side_navigation_test_utils.Get()->stream_registry(); |
65 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); | 65 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); |
66 stream->Finalize(net::OK); | 66 stream->Finalize(net::OK); |
67 return stream->CreateHandle(); | 67 return stream->CreateHandle(); |
68 } | 68 } |
69 | 69 |
70 void EnableBrowserSideNavigation() { | 70 void EnableBrowserSideNavigation() { |
71 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 71 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
72 switches::kEnableBrowserSideNavigation); | 72 switches::kEnableBrowserSideNavigation); |
73 } | 73 } |
74 | 74 |
75 } // namespace content | 75 } // namespace content |
OLD | NEW |