| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/test/browser_side_navigation_test_utils.h" | 5 #include "content/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 17 matching lines...) Expand all Loading... |
| 28 public: | 28 public: |
| 29 BrowserSideNavigationTestUtils() | 29 BrowserSideNavigationTestUtils() |
| 30 : stream_registry_(new StreamRegistry), | 30 : stream_registry_(new StreamRegistry), |
| 31 loader_factory_(new TestNavigationURLLoaderFactory) { | 31 loader_factory_(new TestNavigationURLLoaderFactory) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 ~BrowserSideNavigationTestUtils() {} | 34 ~BrowserSideNavigationTestUtils() {} |
| 35 StreamRegistry* stream_registry() { return stream_registry_.get();} | 35 StreamRegistry* stream_registry() { return stream_registry_.get();} |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 scoped_ptr<StreamRegistry> stream_registry_; | 38 std::unique_ptr<StreamRegistry> stream_registry_; |
| 39 scoped_ptr<TestNavigationURLLoaderFactory> loader_factory_; | 39 std::unique_ptr<TestNavigationURLLoaderFactory> loader_factory_; |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(BrowserSideNavigationTestUtils); | 41 DISALLOW_COPY_AND_ASSIGN(BrowserSideNavigationTestUtils); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 base::LazyInstance<scoped_ptr<BrowserSideNavigationTestUtils>> | 44 base::LazyInstance<std::unique_ptr<BrowserSideNavigationTestUtils>> |
| 45 browser_side_navigation_test_utils; | 45 browser_side_navigation_test_utils; |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 void BrowserSideNavigationSetUp() { | 49 void BrowserSideNavigationSetUp() { |
| 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 51 browser_side_navigation_test_utils.Get().reset( | 51 browser_side_navigation_test_utils.Get().reset( |
| 52 new BrowserSideNavigationTestUtils); | 52 new BrowserSideNavigationTestUtils); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void BrowserSideNavigationTearDown() { | 55 void BrowserSideNavigationTearDown() { |
| 56 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 56 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 57 browser_side_navigation_test_utils.Get().reset(nullptr); | 57 browser_side_navigation_test_utils.Get().reset(nullptr); |
| 58 } | 58 } |
| 59 | 59 |
| 60 scoped_ptr<StreamHandle> MakeEmptyStream() { | 60 std::unique_ptr<StreamHandle> MakeEmptyStream() { |
| 61 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); | 61 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID()); |
| 62 StreamRegistry* stream_registry = | 62 StreamRegistry* stream_registry = |
| 63 browser_side_navigation_test_utils.Get()->stream_registry(); | 63 browser_side_navigation_test_utils.Get()->stream_registry(); |
| 64 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); | 64 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); |
| 65 stream->Finalize(); | 65 stream->Finalize(); |
| 66 return stream->CreateHandle(); | 66 return stream->CreateHandle(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void EnableBrowserSideNavigation() { | 69 void EnableBrowserSideNavigation() { |
| 70 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 70 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 71 switches::kEnableBrowserSideNavigation); | 71 switches::kEnableBrowserSideNavigation); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace content | 74 } // namespace content |
| OLD | NEW |