| 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
|
|
|