summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorkhushalsagar <khushalsagar@chromium.org>2016-01-14 13:10:18 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-14 22:03:07 +0000
commit0b3d9e187d64ec49a856019d54c9f7c8e9311b9e (patch)
tree1e24e427cf8f11c9933f8365463a0c941cb34c5f /cc
parente07af4345156a7b1fb67d858db5a3a57f3880b2f (diff)
downloadchromium_src-0b3d9e187d64ec49a856019d54c9f7c8e9311b9e.zip
chromium_src-0b3d9e187d64ec49a856019d54c9f7c8e9311b9e.tar.gz
chromium_src-0b3d9e187d64ec49a856019d54c9f7c8e9311b9e.tar.bz2
cc:: (De)-serialize CommitEarlyOutReason to protobuf
BUG=550687 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1583023004 Cr-Commit-Position: refs/heads/master@{#369541}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn2
-rw-r--r--cc/cc.gyp2
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/proto/BUILD.gn1
-rw-r--r--cc/proto/commit_earlyout_reason.proto20
-rw-r--r--cc/scheduler/commit_earlyout_reason.cc47
-rw-r--r--cc/scheduler/commit_earlyout_reason.h13
-rw-r--r--cc/scheduler/commit_earlyout_reason_unittest.cc39
8 files changed, 125 insertions, 0 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index fa11da8..353958d 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -429,6 +429,7 @@ component("cc") {
"scheduler/begin_frame_source.h",
"scheduler/begin_frame_tracker.cc",
"scheduler/begin_frame_tracker.h",
+ "scheduler/commit_earlyout_reason.cc",
"scheduler/commit_earlyout_reason.h",
"scheduler/compositor_timing_history.cc",
"scheduler/compositor_timing_history.h",
@@ -856,6 +857,7 @@ test("cc_unittests") {
"resources/scoped_resource_unittest.cc",
"resources/video_resource_updater_unittest.cc",
"scheduler/begin_frame_source_unittest.cc",
+ "scheduler/commit_earlyout_reason_unittest.cc",
"scheduler/compositor_timing_history_unittest.cc",
"scheduler/delay_based_time_source_unittest.cc",
"scheduler/scheduler_state_machine_unittest.cc",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 19762e1..7ad323a 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -492,6 +492,7 @@
'scheduler/begin_frame_source.h',
'scheduler/begin_frame_tracker.cc',
'scheduler/begin_frame_tracker.h',
+ 'scheduler/commit_earlyout_reason.cc',
'scheduler/commit_earlyout_reason.h',
'scheduler/compositor_timing_history.cc',
'scheduler/compositor_timing_history.h',
@@ -604,6 +605,7 @@
'target_name': 'cc_proto',
'type': '<(component)',
'sources': [
+ 'proto/commit_earlyout_reason.proto',
'proto/compositor_message.proto',
'proto/display_item.proto',
'proto/display_list_recording_source.proto',
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index ff16a5a..0d5f6b1 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -109,6 +109,7 @@
'resources/scoped_resource_unittest.cc',
'resources/video_resource_updater_unittest.cc',
'scheduler/begin_frame_source_unittest.cc',
+ 'scheduler/commit_earlyout_reason_unittest.cc',
'scheduler/compositor_timing_history_unittest.cc',
'scheduler/delay_based_time_source_unittest.cc',
'scheduler/scheduler_state_machine_unittest.cc',
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index 0817160..60952ac 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -29,6 +29,7 @@ proto_library("proto_internal") {
sources = [
# TODO(dtrainor): Move protos to their correct packages once it's possible
# to include protos from other directories/targets (crbug.com/542423).
+ "commit_earlyout_reason.proto",
"compositor_message.proto",
"display_item.proto",
"display_list_recording_source.proto",
diff --git a/cc/proto/commit_earlyout_reason.proto b/cc/proto/commit_earlyout_reason.proto
new file mode 100644
index 0000000..100b94b
--- /dev/null
+++ b/cc/proto/commit_earlyout_reason.proto
@@ -0,0 +1,20 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+syntax = "proto2";
+
+option optimize_for = LITE_RUNTIME;
+
+package cc.proto;
+
+message CommitEarlyOutReason {
+ enum Reason {
+ ABORTED_OUTPUT_SURFACE_LOST = 1;
+ ABORTED_NOT_VISIBLE = 2;
+ ABORTED_DEFERRED_COMMIT = 3;
+ FINISHED_NO_UPDATES = 4;
+ }
+
+ optional Reason reason = 1;
+} \ No newline at end of file
diff --git a/cc/scheduler/commit_earlyout_reason.cc b/cc/scheduler/commit_earlyout_reason.cc
new file mode 100644
index 0000000..8b87519
--- /dev/null
+++ b/cc/scheduler/commit_earlyout_reason.cc
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/scheduler/commit_earlyout_reason.h"
+
+#include "cc/proto/commit_earlyout_reason.pb.h"
+
+namespace cc {
+
+CommitEarlyOutReason CommitEarlyOutReasonFromProtobuf(
+ const proto::CommitEarlyOutReason& proto) {
+ switch (proto.reason()) {
+ case proto::CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
+ return CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST;
+ case proto::CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
+ return CommitEarlyOutReason::ABORTED_NOT_VISIBLE;
+ case proto::CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT:
+ return CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT;
+ case proto::CommitEarlyOutReason::FINISHED_NO_UPDATES:
+ return CommitEarlyOutReason::FINISHED_NO_UPDATES;
+ }
+ NOTREACHED();
+ return CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST;
+}
+
+void CommitEarlyOutReasonToProtobuf(CommitEarlyOutReason reason,
+ proto::CommitEarlyOutReason* proto) {
+ switch (reason) {
+ case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
+ proto->set_reason(
+ proto::CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
+ return;
+ case CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
+ proto->set_reason(proto::CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
+ return;
+ case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT:
+ proto->set_reason(proto::CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT);
+ return;
+ case CommitEarlyOutReason::FINISHED_NO_UPDATES:
+ proto->set_reason(proto::CommitEarlyOutReason::FINISHED_NO_UPDATES);
+ return;
+ }
+ NOTREACHED();
+}
+
+} // namespace cc
diff --git a/cc/scheduler/commit_earlyout_reason.h b/cc/scheduler/commit_earlyout_reason.h
index 14aaeb3..f9346d8 100644
--- a/cc/scheduler/commit_earlyout_reason.h
+++ b/cc/scheduler/commit_earlyout_reason.h
@@ -6,9 +6,14 @@
#define CC_SCHEDULER_COMMIT_EARLYOUT_REASON_H_
#include "base/logging.h"
+#include "cc/base/cc_export.h"
namespace cc {
+namespace proto {
+class CommitEarlyOutReason;
+}
+
enum class CommitEarlyOutReason {
ABORTED_OUTPUT_SURFACE_LOST,
ABORTED_NOT_VISIBLE,
@@ -16,6 +21,14 @@ enum class CommitEarlyOutReason {
FINISHED_NO_UPDATES,
};
+// Please update the To/From Protobuf methods for any updates made to
+// CommitEarlyOutReason enum.
+CC_EXPORT CommitEarlyOutReason
+CommitEarlyOutReasonFromProtobuf(const proto::CommitEarlyOutReason& proto);
+CC_EXPORT void CommitEarlyOutReasonToProtobuf(
+ CommitEarlyOutReason reason,
+ proto::CommitEarlyOutReason* proto);
+
inline const char* CommitEarlyOutReasonToString(CommitEarlyOutReason reason) {
switch (reason) {
case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
diff --git a/cc/scheduler/commit_earlyout_reason_unittest.cc b/cc/scheduler/commit_earlyout_reason_unittest.cc
new file mode 100644
index 0000000..44d04dc
--- /dev/null
+++ b/cc/scheduler/commit_earlyout_reason_unittest.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/scheduler/commit_earlyout_reason.h"
+
+#include "cc/proto/commit_earlyout_reason.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+CommitEarlyOutReason SerializeAndDeserializeReason(
+ CommitEarlyOutReason reason) {
+ proto::CommitEarlyOutReason proto;
+ CommitEarlyOutReasonToProtobuf(reason, &proto);
+ return CommitEarlyOutReasonFromProtobuf(proto);
+}
+
+TEST(CommitEarlyOutReasonUnittest, SerializeCommitEarlyOutReason) {
+ EXPECT_EQ(CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST,
+ SerializeAndDeserializeReason(
+ CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST));
+
+ EXPECT_EQ(
+ CommitEarlyOutReason::ABORTED_NOT_VISIBLE,
+ SerializeAndDeserializeReason(CommitEarlyOutReason::ABORTED_NOT_VISIBLE));
+
+ EXPECT_EQ(CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT,
+ SerializeAndDeserializeReason(
+ CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT));
+
+ EXPECT_EQ(
+ CommitEarlyOutReason::FINISHED_NO_UPDATES,
+ SerializeAndDeserializeReason(CommitEarlyOutReason::FINISHED_NO_UPDATES));
+}
+
+} // namespace
+} // namespace cc