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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/utility/media_galleries/ipc_tunnel_data_reader.h"
6
7 #include "chrome/common/chrome_utility_messages.h"
8 #include "content/public/utility/utility_thread.h"
9
10 namespace metadata {
11
12 IPCTunnelDataReader::IPCTunnelDataReader() : next_request_id_(0) {}
13
14 IPCTunnelDataReader::~IPCTunnelDataReader() {}
15
16 void IPCTunnelDataReader::ReadBytes(int64 offset, int64 length,
17 const ReadBytesCallback& callback) {
18 int64 request_id = ++next_request_id_;
19 pending_callbacks_[request_id] = callback;
20 content::UtilityThread::Get()->Send(
21 new ChromeUtilityHostMsg_ParseMediaMetadata_RequestBlobBytes(
22 request_id, offset, length));
23 }
24
25 void IPCTunnelDataReader::ReceiveBytes(int64 request_id,
26 const std::string& bytes) {
27 std::map<int64, ReadBytesCallback>::iterator it =
28 pending_callbacks_.find(request_id);
29
30 if (it == pending_callbacks_.end())
31 return;
32
33 it->second.Run(bytes);
34
35 pending_callbacks_.erase(it);
36 }
37
38 } // namespace metadata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698