summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormithro@mithis.com <mithro@mithis.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-10 02:16:02 +0000
committermithro@mithis.com <mithro@mithis.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-10 02:16:02 +0000
commitfc441c6d790e1b8e7bf890cebe6c7577317a158c (patch)
treea1749683debd74a55c42b92f8685db43ef9407b7
parent9d70de1a6c9c22c1ea9baa2ea02233dcc0cf5479 (diff)
downloadchromium_src-fc441c6d790e1b8e7bf890cebe6c7577317a158c.zip
chromium_src-fc441c6d790e1b8e7bf890cebe6c7577317a158c.tar.gz
chromium_src-fc441c6d790e1b8e7bf890cebe6c7577317a158c.tar.bz2
Making BeginFrameArgs work with TRACE_EVENT system.
* Added ToValue() method on BeginFrameArgs. * Added a ToTrace method inside cc/traced_value.h for easy conversion, just do a ToTrace(XXX) of anything which has a ToValue() method. * Rename Scheduler::StateAsValue to AsValue so it works with above. BUG=371223 Review URL: https://codereview.chromium.org/270703004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269487 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/debug/traced_value.h11
-rw-r--r--cc/output/begin_frame_args.cc10
-rw-r--r--cc/output/begin_frame_args.h3
-rw-r--r--cc/scheduler/scheduler.cc14
-rw-r--r--cc/scheduler/scheduler.h2
-rw-r--r--cc/scheduler/scheduler_unittest.cc28
-rw-r--r--cc/trees/proxy.cc2
-rw-r--r--cc/trees/proxy.h2
-rw-r--r--cc/trees/thread_proxy.cc10
-rw-r--r--cc/trees/thread_proxy.h5
10 files changed, 56 insertions, 31 deletions
diff --git a/cc/debug/traced_value.h b/cc/debug/traced_value.h
index e96c09a..560eaf8 100644
--- a/cc/debug/traced_value.h
+++ b/cc/debug/traced_value.h
@@ -46,6 +46,17 @@ class TracedValue : public base::debug::ConvertableToTraceFormat {
DISALLOW_COPY_AND_ASSIGN(TracedValue);
};
+template <class T>
+static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace(T* t) {
+ return TracedValue::FromValue(t->AsValue().release());
+}
+
+template <class T>
+static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace(
+ const T& t) {
+ return ToTrace(&t);
+}
+
} // namespace cc
#endif // CC_DEBUG_TRACED_VALUE_H_
diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc
index 9766b626..2d7cd96 100644
--- a/cc/output/begin_frame_args.cc
+++ b/cc/output/begin_frame_args.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/json/json_writer.h"
#include "cc/output/begin_frame_args.h"
#include "ui/gfx/frame_time.h"
@@ -27,6 +28,15 @@ BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
return BeginFrameArgs(frame_time, deadline, interval);
}
+scoped_ptr<base::Value> BeginFrameArgs::AsValue() const {
+ scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
+ state->SetString("type", "BeginFrameArgs");
+ state->SetDouble("frame_time_us", frame_time.ToInternalValue());
+ state->SetDouble("deadline_us", deadline.ToInternalValue());
+ state->SetDouble("interval_us", interval.InMicroseconds());
+ return state.PassAs<base::Value>();
+}
+
BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() {
// For WebView/SynchronousCompositor, we always want to draw immediately,
// so we set the deadline to 0 and guess that the interval is 16 milliseconds.
diff --git a/cc/output/begin_frame_args.h b/cc/output/begin_frame_args.h
index 2332fd4..4bc352b 100644
--- a/cc/output/begin_frame_args.h
+++ b/cc/output/begin_frame_args.h
@@ -6,6 +6,7 @@
#define CC_OUTPUT_BEGIN_FRAME_ARGS_H_
#include "base/time/time.h"
+#include "base/values.h"
#include "cc/base/cc_export.h"
namespace cc {
@@ -37,6 +38,8 @@ struct CC_EXPORT BeginFrameArgs {
bool IsValid() const { return interval >= base::TimeDelta(); }
+ scoped_ptr<base::Value> AsValue() const;
+
base::TimeTicks frame_time;
base::TimeTicks deadline;
base::TimeDelta interval;
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 88c8c74..bf38cb3 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -394,7 +394,7 @@ void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) {
// If the scheduler is busy, we queue the BeginFrame to be handled later as
// a BeginRetroFrame.
void Scheduler::BeginFrame(const BeginFrameArgs& args) {
- TRACE_EVENT1("cc", "Scheduler::BeginFrame", "frame_time", args.frame_time);
+ TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", ToTrace(args));
DCHECK(settings_.throttle_frame_production);
bool should_defer_begin_frame;
@@ -488,8 +488,7 @@ void Scheduler::PostBeginRetroFrameIfNeeded() {
// for a BeginMainFrame+activation to complete before it times out and draws
// any asynchronous animation and scroll/pinch updates.
void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
- TRACE_EVENT1(
- "cc", "Scheduler::BeginImplFrame", "frame_time", args.frame_time);
+ TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", ToTrace(args));
DCHECK(state_machine_.begin_impl_frame_state() ==
SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
DCHECK(state_machine_.HasInitializedOutputSurface());
@@ -630,7 +629,7 @@ void Scheduler::ProcessScheduledActions() {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
"SchedulerStateMachine",
"state",
- TracedValue::FromValue(StateAsValue().release()));
+ ToTrace(this));
state_machine_.UpdateState(action);
base::AutoReset<SchedulerStateMachine::Action>
mark_inside_action(&inside_action_, action);
@@ -687,7 +686,7 @@ bool Scheduler::WillDrawIfNeeded() const {
return !state_machine_.PendingDrawsShouldBeAborted();
}
-scoped_ptr<base::Value> Scheduler::StateAsValue() const {
+scoped_ptr<base::Value> Scheduler::AsValue() const {
scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
state->Set("state_machine", state_machine_.AsValue().release());
@@ -713,6 +712,9 @@ scoped_ptr<base::Value> Scheduler::StateAsValue() const {
!poll_for_draw_triggers_task_.IsCancelled());
scheduler_state->SetBoolean("advance_commit_state_task_",
!advance_commit_state_task_.IsCancelled());
+ scheduler_state->Set("begin_impl_frame_args",
+ begin_impl_frame_args_.AsValue().release());
+
state->Set("scheduler_state", scheduler_state.release());
scoped_ptr<base::DictionaryValue> client_state(new base::DictionaryValue);
@@ -742,7 +744,7 @@ bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
"time_left_after_drawing_ms",
(begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(),
"state",
- TracedValue::FromValue(StateAsValue().release()));
+ ToTrace(this));
return estimated_draw_time < begin_impl_frame_args_.deadline;
}
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h
index 1e59192..b30f06e 100644
--- a/cc/scheduler/scheduler.h
+++ b/cc/scheduler/scheduler.h
@@ -137,7 +137,7 @@ class CC_EXPORT Scheduler {
void PollForAnticipatedDrawTriggers();
void PollToAdvanceCommitState();
- scoped_ptr<base::Value> StateAsValue() const;
+ scoped_ptr<base::Value> AsValue() const;
bool IsInsideAction(SchedulerStateMachine::Action action) {
return inside_action_ == action;
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index e69e6dd..d307f96 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -99,25 +99,25 @@ class FakeSchedulerClient : public SchedulerClient {
// SchedulerClient implementation.
virtual void SetNeedsBeginFrame(bool enable) OVERRIDE {
actions_.push_back("SetNeedsBeginFrame");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
needs_begin_frame_ = enable;
}
virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE {
actions_.push_back("WillBeginImplFrame");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {
actions_.push_back("ScheduledActionSendBeginMainFrame");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionAnimate() OVERRIDE {
actions_.push_back("ScheduledActionAnimate");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
OVERRIDE {
actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
num_draws_++;
bool did_readback = false;
DrawSwapReadbackResult::DrawResult result =
@@ -138,7 +138,7 @@ class FakeSchedulerClient : public SchedulerClient {
}
virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE {
actions_.push_back("ScheduledActionDrawAndSwapForced");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
bool did_request_swap = swap_will_happen_if_draw_happens_;
bool did_readback = false;
return DrawSwapReadbackResult(
@@ -146,7 +146,7 @@ class FakeSchedulerClient : public SchedulerClient {
}
virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE {
actions_.push_back("ScheduledActionDrawAndReadback");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
bool did_request_swap = false;
bool did_readback = true;
return DrawSwapReadbackResult(
@@ -154,23 +154,23 @@ class FakeSchedulerClient : public SchedulerClient {
}
virtual void ScheduledActionCommit() OVERRIDE {
actions_.push_back("ScheduledActionCommit");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE {
actions_.push_back("ScheduledActionUpdateVisibleTiles");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionActivatePendingTree() OVERRIDE {
actions_.push_back("ScheduledActionActivatePendingTree");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {
actions_.push_back("ScheduledActionBeginOutputSurfaceCreation");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void ScheduledActionManageTiles() OVERRIDE {
actions_.push_back("ScheduledActionManageTiles");
- states_.push_back(scheduler_->StateAsValue().release());
+ states_.push_back(scheduler_->AsValue().release());
}
virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {
if (log_anticipated_draw_time_change_)
@@ -1115,7 +1115,7 @@ TEST(SchedulerTest, PollForCommitCompletion) {
for (int i = 0; i < 3; ++i) {
EXPECT_EQ((frame_args.interval * 2).InMicroseconds(),
client.task_runner().NextPendingTaskDelay().InMicroseconds())
- << *scheduler->StateAsValue();
+ << *scheduler->AsValue();
client.task_runner().RunPendingTasks();
EXPECT_GT(client.num_actions_(), actions_so_far);
EXPECT_STREQ(client.Action(client.num_actions_() - 1),
@@ -1128,7 +1128,7 @@ TEST(SchedulerTest, PollForCommitCompletion) {
for (int i = 0; i < 3; ++i) {
EXPECT_EQ((frame_args.interval * 2).InMicroseconds(),
client.task_runner().NextPendingTaskDelay().InMicroseconds())
- << *scheduler->StateAsValue();
+ << *scheduler->AsValue();
client.task_runner().RunPendingTasks();
EXPECT_GT(client.num_actions_(), actions_so_far);
EXPECT_STREQ(client.Action(client.num_actions_() - 1),
diff --git a/cc/trees/proxy.cc b/cc/trees/proxy.cc
index d9477cb..66967a6 100644
--- a/cc/trees/proxy.cc
+++ b/cc/trees/proxy.cc
@@ -77,7 +77,7 @@ Proxy::~Proxy() {
DCHECK(IsMainThread());
}
-scoped_ptr<base::Value> Proxy::SchedulerStateAsValueForTesting() {
+scoped_ptr<base::Value> Proxy::SchedulerAsValueForTesting() {
return make_scoped_ptr(base::Value::CreateNullValue());
}
diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h
index 5c72571..7ab4a89 100644
--- a/cc/trees/proxy.h
+++ b/cc/trees/proxy.h
@@ -101,7 +101,7 @@ class CC_EXPORT Proxy {
// Testing hooks
virtual bool CommitPendingForTesting() = 0;
- virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting();
+ virtual scoped_ptr<base::Value> SchedulerAsValueForTesting();
protected:
explicit Proxy(
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 19cf3ba..0483234 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -1530,16 +1530,16 @@ void ThreadProxy::CommitPendingOnImplThreadForTesting(
request->completion.Signal();
}
-scoped_ptr<base::Value> ThreadProxy::SchedulerStateAsValueForTesting() {
+scoped_ptr<base::Value> ThreadProxy::SchedulerAsValueForTesting() {
if (IsImplThread())
- return impl().scheduler->StateAsValue().Pass();
+ return impl().scheduler->AsValue().Pass();
SchedulerStateRequest scheduler_state_request;
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
Proxy::ImplThreadTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&ThreadProxy::SchedulerStateAsValueOnImplThreadForTesting,
+ base::Bind(&ThreadProxy::SchedulerAsValueOnImplThreadForTesting,
impl_thread_weak_ptr_,
&scheduler_state_request));
scheduler_state_request.completion.Wait();
@@ -1547,10 +1547,10 @@ scoped_ptr<base::Value> ThreadProxy::SchedulerStateAsValueForTesting() {
return scheduler_state_request.state.Pass();
}
-void ThreadProxy::SchedulerStateAsValueOnImplThreadForTesting(
+void ThreadProxy::SchedulerAsValueOnImplThreadForTesting(
SchedulerStateRequest* request) {
DCHECK(IsImplThread());
- request->state = impl().scheduler->StateAsValue();
+ request->state = impl().scheduler->AsValue();
request->completion.Signal();
}
diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h
index f91599e..8df7958 100644
--- a/cc/trees/thread_proxy.h
+++ b/cc/trees/thread_proxy.h
@@ -68,7 +68,7 @@ class ThreadProxy : public Proxy,
virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE;
virtual scoped_ptr<base::Value> AsValue() const OVERRIDE;
virtual bool CommitPendingForTesting() OVERRIDE;
- virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting() OVERRIDE;
+ virtual scoped_ptr<base::Value> SchedulerAsValueForTesting() OVERRIDE;
// LayerTreeHostImplClient implementation
virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE;
@@ -188,8 +188,7 @@ class ThreadProxy : public Proxy,
void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion);
void CheckOutputSurfaceStatusOnImplThread();
void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request);
- void SchedulerStateAsValueOnImplThreadForTesting(
- SchedulerStateRequest* request);
+ void SchedulerAsValueOnImplThreadForTesting(SchedulerStateRequest* request);
void AsValueOnImplThread(CompletionEvent* completion,
base::DictionaryValue* state) const;
void RenewTreePriorityOnImplThread();