Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: extensions/browser/load_monitoring_extension_host_queue_unittest.cc

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "extensions/browser/load_monitoring_extension_host_queue.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
7 #include <limits> 9 #include <limits>
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/memory/ptr_util.h"
11 #include "base/run_loop.h" 14 #include "base/run_loop.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "extensions/browser/deferred_start_render_host.h" 16 #include "extensions/browser/deferred_start_render_host.h"
14 #include "extensions/browser/extensions_test.h" 17 #include "extensions/browser/extensions_test.h"
15 #include "extensions/browser/load_monitoring_extension_host_queue.h"
16 #include "extensions/browser/serial_extension_host_queue.h" 18 #include "extensions/browser/serial_extension_host_queue.h"
17 19
18 namespace extensions { 20 namespace extensions {
19 21
20 namespace { 22 namespace {
21 23
22 class StubDeferredStartRenderHost : public DeferredStartRenderHost { 24 class StubDeferredStartRenderHost : public DeferredStartRenderHost {
23 public: 25 public:
24 // Returns true if this host is being observed by |observer|. 26 // Returns true if this host is being observed by |observer|.
25 bool IsObservedBy(DeferredStartRenderHostObserver* observer) { 27 bool IsObservedBy(DeferredStartRenderHostObserver* observer) {
(...skipping 25 matching lines...) Expand all
51 : finished_(false), 53 : finished_(false),
52 // Arbitrary choice of an invalid size_t. 54 // Arbitrary choice of an invalid size_t.
53 num_queued_(g_invalid_size_t), 55 num_queued_(g_invalid_size_t),
54 num_loaded_(g_invalid_size_t), 56 num_loaded_(g_invalid_size_t),
55 max_awaiting_loading_(g_invalid_size_t), 57 max_awaiting_loading_(g_invalid_size_t),
56 max_active_loading_(g_invalid_size_t) {} 58 max_active_loading_(g_invalid_size_t) {}
57 59
58 void SetUp() override { 60 void SetUp() override {
59 queue_.reset(new LoadMonitoringExtensionHostQueue( 61 queue_.reset(new LoadMonitoringExtensionHostQueue(
60 // Use a SerialExtensionHostQueue because it's simple. 62 // Use a SerialExtensionHostQueue because it's simple.
61 scoped_ptr<ExtensionHostQueue>(new SerialExtensionHostQueue()), 63 std::unique_ptr<ExtensionHostQueue>(new SerialExtensionHostQueue()),
62 base::TimeDelta(), // no delay, easier to test 64 base::TimeDelta(), // no delay, easier to test
63 base::Bind(&LoadMonitoringExtensionHostQueueTest::Finished, 65 base::Bind(&LoadMonitoringExtensionHostQueueTest::Finished,
64 base::Unretained(this)))); 66 base::Unretained(this))));
65 } 67 }
66 68
67 protected: 69 protected:
68 // Creates a new DeferredStartRenderHost. Ownership is held by this class, 70 // Creates a new DeferredStartRenderHost. Ownership is held by this class,
69 // not passed to caller. 71 // not passed to caller.
70 StubDeferredStartRenderHost* CreateHost() { 72 StubDeferredStartRenderHost* CreateHost() {
71 stubs_.push_back(make_scoped_ptr(new StubDeferredStartRenderHost())); 73 stubs_.push_back(base::WrapUnique(new StubDeferredStartRenderHost()));
72 return stubs_.back().get(); 74 return stubs_.back().get();
73 } 75 }
74 76
75 // Our single LoadMonitoringExtensionHostQueue instance. 77 // Our single LoadMonitoringExtensionHostQueue instance.
76 LoadMonitoringExtensionHostQueue* queue() { return queue_.get(); } 78 LoadMonitoringExtensionHostQueue* queue() { return queue_.get(); }
77 79
78 // Returns true if the queue has finished monitoring. 80 // Returns true if the queue has finished monitoring.
79 bool finished() const { return finished_; } 81 bool finished() const { return finished_; }
80 82
81 // These are available after the queue has finished (in which case finished() 83 // These are available after the queue has finished (in which case finished()
(...skipping 11 matching lines...) Expand all
93 size_t max_active_loading) { 95 size_t max_active_loading) {
94 CHECK(!finished_); 96 CHECK(!finished_);
95 finished_ = true; 97 finished_ = true;
96 num_queued_ = num_queued; 98 num_queued_ = num_queued;
97 num_loaded_ = num_loaded; 99 num_loaded_ = num_loaded;
98 max_awaiting_loading_ = max_awaiting_loading; 100 max_awaiting_loading_ = max_awaiting_loading;
99 max_active_loading_ = max_active_loading; 101 max_active_loading_ = max_active_loading;
100 } 102 }
101 103
102 content::TestBrowserThreadBundle thread_bundle_; 104 content::TestBrowserThreadBundle thread_bundle_;
103 scoped_ptr<LoadMonitoringExtensionHostQueue> queue_; 105 std::unique_ptr<LoadMonitoringExtensionHostQueue> queue_;
104 std::vector<scoped_ptr<StubDeferredStartRenderHost>> stubs_; 106 std::vector<std::unique_ptr<StubDeferredStartRenderHost>> stubs_;
105 107
106 // Set after the queue has finished monitoring. 108 // Set after the queue has finished monitoring.
107 bool finished_; 109 bool finished_;
108 size_t num_queued_; 110 size_t num_queued_;
109 size_t num_loaded_; 111 size_t num_loaded_;
110 size_t max_awaiting_loading_; 112 size_t max_awaiting_loading_;
111 size_t max_active_loading_; 113 size_t max_active_loading_;
112 }; 114 };
113 115
114 // Tests that if monitoring is never started, nor any hosts added, nothing is 116 // Tests that if monitoring is never started, nor any hosts added, nothing is
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 queue()->Remove(host3); 348 queue()->Remove(host3);
347 queue()->Remove(host4); 349 queue()->Remove(host4);
348 350
349 EXPECT_FALSE(host1->IsObservedBy(queue())); 351 EXPECT_FALSE(host1->IsObservedBy(queue()));
350 EXPECT_FALSE(host2->IsObservedBy(queue())); 352 EXPECT_FALSE(host2->IsObservedBy(queue()));
351 EXPECT_FALSE(host3->IsObservedBy(queue())); 353 EXPECT_FALSE(host3->IsObservedBy(queue()));
352 EXPECT_FALSE(host4->IsObservedBy(queue())); 354 EXPECT_FALSE(host4->IsObservedBy(queue()));
353 } 355 }
354 356
355 } // namespace extensions 357 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/load_monitoring_extension_host_queue.cc ('k') | extensions/browser/mock_extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698