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

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/debug/trace_event_argument.h"
13 #include "base/debug/trace_event_synthetic_delay.h" 14 #include "base/debug/trace_event_synthetic_delay.h"
14 #include "cc/base/swap_promise.h" 15 #include "cc/base/swap_promise.h"
15 #include "cc/debug/benchmark_instrumentation.h" 16 #include "cc/debug/benchmark_instrumentation.h"
16 #include "cc/debug/devtools_instrumentation.h" 17 #include "cc/debug/devtools_instrumentation.h"
17 #include "cc/input/input_handler.h" 18 #include "cc/input/input_handler.h"
18 #include "cc/output/context_provider.h" 19 #include "cc/output/context_provider.h"
19 #include "cc/output/output_surface.h" 20 #include "cc/output/output_surface.h"
20 #include "cc/quads/draw_quad.h" 21 #include "cc/quads/draw_quad.h"
21 #include "cc/resources/prioritized_resource_manager.h" 22 #include "cc/resources/prioritized_resource_manager.h"
22 #include "cc/scheduler/delay_based_time_source.h" 23 #include "cc/scheduler/delay_based_time_source.h"
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 return ResourceUpdateController::MaxPartialTextureUpdates(); 1289 return ResourceUpdateController::MaxPartialTextureUpdates();
1289 } 1290 }
1290 1291
1291 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() 1292 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState()
1292 : memory_allocation_limit_bytes(0), 1293 : memory_allocation_limit_bytes(0),
1293 memory_allocation_priority_cutoff(0), 1294 memory_allocation_priority_cutoff(0),
1294 evicted_ui_resources(false) {} 1295 evicted_ui_resources(false) {}
1295 1296
1296 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} 1297 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {}
1297 1298
1298 scoped_ptr<base::Value> ThreadProxy::AsValue() const { 1299 void ThreadProxy::AsValueInto(base::debug::TracedValue* state) const {
1299 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1300
1301 CompletionEvent completion; 1300 CompletionEvent completion;
1302 { 1301 {
1303 DebugScopedSetMainThreadBlocked main_thread_blocked( 1302 DebugScopedSetMainThreadBlocked main_thread_blocked(
1304 const_cast<ThreadProxy*>(this)); 1303 const_cast<ThreadProxy*>(this));
1304 scoped_refptr<base::debug::TracedValue> state_refptr(state);
1305 Proxy::ImplThreadTaskRunner()->PostTask( 1305 Proxy::ImplThreadTaskRunner()->PostTask(
1306 FROM_HERE, 1306 FROM_HERE,
1307 base::Bind(&ThreadProxy::AsValueOnImplThread, 1307 base::Bind(&ThreadProxy::AsValueOnImplThread,
1308 impl_thread_weak_ptr_, 1308 impl_thread_weak_ptr_,
1309 &completion, 1309 &completion,
1310 state.get())); 1310 state_refptr));
1311 completion.Wait(); 1311 completion.Wait();
1312 } 1312 }
1313 return state.PassAs<base::Value>();
1314 } 1313 }
1315 1314
1316 void ThreadProxy::AsValueOnImplThread(CompletionEvent* completion, 1315 void ThreadProxy::AsValueOnImplThread(CompletionEvent* completion,
1317 base::DictionaryValue* state) const { 1316 base::debug::TracedValue* state) const {
1318 state->Set("layer_tree_host_impl", 1317 state->BeginDictionary("layer_tree_host_impl");
1319 impl().layer_tree_host_impl->AsValue().release()); 1318 impl().layer_tree_host_impl->AsValueInto(state);
1319 state->EndDictionary();
1320 completion->Signal(); 1320 completion->Signal();
1321 } 1321 }
1322 1322
1323 bool ThreadProxy::CommitPendingForTesting() { 1323 bool ThreadProxy::CommitPendingForTesting() {
1324 DCHECK(IsMainThread()); 1324 DCHECK(IsMainThread());
1325 CommitPendingRequest commit_pending_request; 1325 CommitPendingRequest commit_pending_request;
1326 { 1326 {
1327 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 1327 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
1328 Proxy::ImplThreadTaskRunner()->PostTask( 1328 Proxy::ImplThreadTaskRunner()->PostTask(
1329 FROM_HERE, 1329 FROM_HERE,
1330 base::Bind(&ThreadProxy::CommitPendingOnImplThreadForTesting, 1330 base::Bind(&ThreadProxy::CommitPendingOnImplThreadForTesting,
1331 impl_thread_weak_ptr_, 1331 impl_thread_weak_ptr_,
1332 &commit_pending_request)); 1332 &commit_pending_request));
1333 commit_pending_request.completion.Wait(); 1333 commit_pending_request.completion.Wait();
1334 } 1334 }
1335 return commit_pending_request.commit_pending; 1335 return commit_pending_request.commit_pending;
1336 } 1336 }
1337 1337
1338 void ThreadProxy::CommitPendingOnImplThreadForTesting( 1338 void ThreadProxy::CommitPendingOnImplThreadForTesting(
1339 CommitPendingRequest* request) { 1339 CommitPendingRequest* request) {
1340 DCHECK(IsImplThread()); 1340 DCHECK(IsImplThread());
1341 if (impl().layer_tree_host_impl->output_surface()) 1341 if (impl().layer_tree_host_impl->output_surface())
1342 request->commit_pending = impl().scheduler->CommitPending(); 1342 request->commit_pending = impl().scheduler->CommitPending();
1343 else 1343 else
1344 request->commit_pending = false; 1344 request->commit_pending = false;
1345 request->completion.Signal(); 1345 request->completion.Signal();
1346 } 1346 }
1347 1347
1348 scoped_ptr<base::Value> ThreadProxy::SchedulerAsValueForTesting() {
1349 if (IsImplThread())
1350 return impl().scheduler->AsValue().Pass();
1351
1352 SchedulerStateRequest scheduler_state_request;
1353 {
1354 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
1355 Proxy::ImplThreadTaskRunner()->PostTask(
1356 FROM_HERE,
1357 base::Bind(&ThreadProxy::SchedulerAsValueOnImplThreadForTesting,
1358 impl_thread_weak_ptr_,
1359 &scheduler_state_request));
1360 scheduler_state_request.completion.Wait();
1361 }
1362 return scheduler_state_request.state.Pass();
1363 }
1364
1365 void ThreadProxy::SchedulerAsValueOnImplThreadForTesting(
1366 SchedulerStateRequest* request) {
1367 DCHECK(IsImplThread());
1368 request->state = impl().scheduler->AsValue();
1369 request->completion.Signal();
1370 }
1371
1372 void ThreadProxy::RenewTreePriority() { 1348 void ThreadProxy::RenewTreePriority() {
1373 DCHECK(IsImplThread()); 1349 DCHECK(IsImplThread());
1374 bool smoothness_takes_priority = 1350 bool smoothness_takes_priority =
1375 impl().layer_tree_host_impl->pinch_gesture_active() || 1351 impl().layer_tree_host_impl->pinch_gesture_active() ||
1376 impl().layer_tree_host_impl->page_scale_animation_active() || 1352 impl().layer_tree_host_impl->page_scale_animation_active() ||
1377 (impl().layer_tree_host_impl->IsCurrentlyScrolling() && 1353 (impl().layer_tree_host_impl->IsCurrentlyScrolling() &&
1378 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); 1354 !impl().layer_tree_host_impl->scroll_affects_scroll_handler());
1379 1355
1380 // Schedule expiration if smoothness currently takes priority. 1356 // Schedule expiration if smoothness currently takes priority.
1381 if (smoothness_takes_priority) 1357 if (smoothness_takes_priority)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 1413
1438 impl().timing_history.DidActivateSyncTree(); 1414 impl().timing_history.DidActivateSyncTree();
1439 } 1415 }
1440 1416
1441 void ThreadProxy::DidManageTiles() { 1417 void ThreadProxy::DidManageTiles() {
1442 DCHECK(IsImplThread()); 1418 DCHECK(IsImplThread());
1443 impl().scheduler->DidManageTiles(); 1419 impl().scheduler->DidManageTiles();
1444 } 1420 }
1445 1421
1446 } // namespace cc 1422 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698