NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / utility / media_galleries / ipc_data_source.h
blobc693c864c9c77bafdde00237770263d12ebf5471
1 // Copyright 2014 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.
5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_
8 #include <map>
9 #include <string>
11 #include "chrome/utility/utility_message_handler.h"
12 #include "media/base/data_source.h"
14 namespace metadata {
16 // Provides the metadata parser with bytes from the browser process via IPC.
17 class IPCDataSource: public media::DataSource,
18 public chrome::UtilityMessageHandler {
19 public:
20 explicit IPCDataSource(int64 total_size);
21 virtual ~IPCDataSource();
23 // Implementation of DataSource.
24 virtual void set_host(media::DataSourceHost* host) OVERRIDE;
25 virtual void Stop(const base::Closure& callback) OVERRIDE;
26 virtual void Read(int64 position, int size, uint8* data,
27 const ReadCB& read_cb) OVERRIDE;
28 virtual bool GetSize(int64* size_out) OVERRIDE;
29 virtual bool IsStreaming() OVERRIDE;
30 virtual void SetBitrate(int bitrate) OVERRIDE;
32 // Implementation of UtilityMessageHandler.
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
35 private:
36 struct Request {
37 Request();
38 ~Request();
39 uint8* destination;
40 ReadCB callback;
43 void OnRequestBlobBytesFinished(int64 request_id,
44 const std::string& bytes);
46 const int64 total_size_;
47 std::map<int64, Request> pending_requests_;
48 int64 next_request_id_;
51 } // namespace metadata
53 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_