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

Unified Diff: content/common/gpu/gpu_messages.cc

Issue 1645873002: Use ParamTraits for media::BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiling errors on mac and address review comments Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/gpu_messages.cc
diff --git a/content/common/gpu/gpu_messages.cc b/content/common/gpu/gpu_messages.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5c9cfc366cc73be73dfc3d0be211448ba61abeb7
--- /dev/null
+++ b/content/common/gpu/gpu_messages.cc
@@ -0,0 +1,65 @@
+// 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.
+
+#include "content/common/gpu/gpu_messages.h"
+
+namespace IPC {
+
+void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m,
+ const param_type& p) {
+ DCHECK_GE(p.id(), 0);
+ DCHECK(base::SharedMemory::IsHandleValid(p.handle()));
+
+ WriteParam(m, p.id());
+ WriteParam(m, static_cast<uint64_t>(p.size()));
+ WriteParam(m, p.presentation_timestamp());
+ WriteParam(m, p.key_id());
+ if (!p.key_id().empty()) {
+ WriteParam(m, p.iv());
+ WriteParam(m, p.subsamples());
+ }
+ WriteParam(m, p.handle());
+}
+
+bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ DCHECK(r);
+ uint64_t size = 0;
+ if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &size) &&
+ ReadParam(m, iter, &r->presentation_timestamp_) &&
+ ReadParam(m, iter, &r->key_id_)))
+ return false;
+
+ if (!base::IsValueInRangeForNumericType<size_t>(size)) {
dcheng 2016/02/18 21:06:09 #include <stddef.h> Also, I think it would be sli
Owen Lin 2016/02/23 03:40:11 Done.
+ LOG(ERROR) << "Invalid size: " << size;
dcheng 2016/02/18 21:06:09 #include "base/logging.h" Also, let's make this (
Owen Lin 2016/02/23 03:40:11 Done.
+ return false;
+ }
+ r->size_ = static_cast<size_t>(size);
+
+ if (r->id_ < 0) {
+ LOG(ERROR) << "Invalid id: " << r->id_;
+ return false;
+ }
+ if (!r->key_id_.empty()) {
+ if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_)))
+ return false;
+ }
+ if (!(ReadParam(m, iter, &r->handle_) &&
+ base::SharedMemory::IsHandleValid(r->handle_))) {
+ LOG(ERROR) << "fail to read valid handle.";
+ return false;
+ }
+ return true;
+}
+
+void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p,
+ std::string* l) {
+ std::ostringstream oss;
dcheng 2016/02/18 21:06:09 #include <sstream>
Owen Lin 2016/02/23 03:40:11 Done.
+ oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp="
+ << p.presentation_timestamp().ToInternalValue();
+ l->append(oss.str());
+}
+
+} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698