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

Side by Side Diff: content/renderer/devtools/v8_sampling_profiler_browsertest.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 (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/renderer/devtools/v8_sampling_profiler.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
9 #include <utility>
10
7 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
8 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
9 #include "base/run_loop.h" 13 #include "base/run_loop.h"
10 #include "base/trace_event/trace_buffer.h" 14 #include "base/trace_event/trace_buffer.h"
11 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
12 #include "content/public/test/render_view_test.h" 16 #include "content/public/test/render_view_test.h"
13 #include "content/renderer/devtools/v8_sampling_profiler.h"
14 17
15 using base::DictionaryValue; 18 using base::DictionaryValue;
16 using base::ListValue; 19 using base::ListValue;
17 using base::Value; 20 using base::Value;
18 using base::trace_event::TraceConfig; 21 using base::trace_event::TraceConfig;
19 using base::trace_event::TraceLog; 22 using base::trace_event::TraceLog;
20 using base::trace_event::TraceResultBuffer; 23 using base::trace_event::TraceResultBuffer;
21 24
22 namespace content { 25 namespace content {
23 26
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 71 }
69 72
70 ListValue* root_list = NULL; 73 ListValue* root_list = NULL;
71 ASSERT_TRUE(root.get()); 74 ASSERT_TRUE(root.get());
72 ASSERT_TRUE(root->GetAsList(&root_list)); 75 ASSERT_TRUE(root->GetAsList(&root_list));
73 76
74 // Move items into our aggregate collection 77 // Move items into our aggregate collection
75 while (root_list->GetSize()) { 78 while (root_list->GetSize()) {
76 std::unique_ptr<Value> item; 79 std::unique_ptr<Value> item;
77 root_list->Remove(0, &item); 80 root_list->Remove(0, &item);
78 trace_parsed_.Append(item.release()); 81 trace_parsed_.Append(std::move(item));
79 } 82 }
80 83
81 if (!has_more_events) 84 if (!has_more_events)
82 flush_complete_event->Signal(); 85 flush_complete_event->Signal();
83 } 86 }
84 87
85 void CollectTrace(int code_added_events, int sample_events) { 88 void CollectTrace(int code_added_events, int sample_events) {
86 TraceLog* trace_log = TraceLog::GetInstance(); 89 TraceLog* trace_log = TraceLog::GetInstance();
87 sampling_profiler_->EnableSamplingEventForTesting(code_added_events, 90 sampling_profiler_->EnableSamplingEventForTesting(code_added_events,
88 sample_events); 91 sample_events);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 146 }
144 147
145 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) { 148 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) {
146 CollectTrace(0, 1); 149 CollectTrace(0, 1);
147 int sample_events_count = CountEvents("V8Sample"); 150 int sample_events_count = CountEvents("V8Sample");
148 CHECK_LT(0, sample_events_count); 151 CHECK_LT(0, sample_events_count);
149 base::RunLoop().RunUntilIdle(); 152 base::RunLoop().RunUntilIdle();
150 } 153 }
151 154
152 } // namespace content 155 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698