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

Unified Diff: chrome/utility/media_galleries/ipc_tunnel_data_reader.cc

Issue 103283003: Media Galleries API Metadata: SafeMediaMetadataParser and IPCTunnelDataReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review 2 Created 7 years 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: chrome/utility/media_galleries/ipc_tunnel_data_reader.cc
diff --git a/chrome/utility/media_galleries/ipc_tunnel_data_reader.cc b/chrome/utility/media_galleries/ipc_tunnel_data_reader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c5417ca5b777c258cd2f0a7669e52416f1f8d295
--- /dev/null
+++ b/chrome/utility/media_galleries/ipc_tunnel_data_reader.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 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 "chrome/utility/media_galleries/ipc_tunnel_data_reader.h"
+
+#include "chrome/common/chrome_utility_messages.h"
+#include "content/public/utility/utility_thread.h"
+
+namespace metadata {
+
+IPCTunnelDataReader::IPCTunnelDataReader() : next_request_id_(0) {}
+
+IPCTunnelDataReader::~IPCTunnelDataReader() {}
+
+void IPCTunnelDataReader::ReadBytes(int64 offset, int64 length,
+ const ReadBytesCallback& callback) {
+ int64 request_id = ++next_request_id_;
+ pending_callbacks_[request_id] = callback;
+ content::UtilityThread::Get()->Send(
+ new ChromeUtilityHostMsg_ParseMediaMetadata_RequestBlobBytes(
+ request_id, offset, length));
+}
+
+void IPCTunnelDataReader::ReceiveBytes(int64 request_id,
+ const std::string& bytes) {
+ std::map<int64, ReadBytesCallback>::iterator it =
+ pending_callbacks_.find(request_id);
+
+ if (it == pending_callbacks_.end())
+ return;
+
+ it->second.Run(bytes);
+
+ pending_callbacks_.erase(it);
+}
+
+} // namespace metadata

Powered by Google App Engine
This is Rietveld 408576698