Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / media / tools / player_x11 / data_source_logger.cc
blobd09b6bf2e1ac99651914042f35aaf9d32dd4de1a
1 // Copyright (c) 2012 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 #include "base/bind.h"
6 #include "base/logging.h"
7 #include "media/tools/player_x11/data_source_logger.h"
9 static void LogAndRunReadCB(
10 int64 position, int size,
11 const media::DataSource::ReadCB& read_cb, int result) {
12 VLOG(1) << "Read(" << position << ", " << size << ") -> " << result;
13 read_cb.Run(result);
16 DataSourceLogger::DataSourceLogger(
17 scoped_ptr<media::DataSource> data_source,
18 bool streaming)
19 : data_source_(data_source.Pass()),
20 streaming_(streaming) {
23 void DataSourceLogger::Stop() {
24 VLOG(1) << "Stop()";
25 data_source_->Stop();
28 void DataSourceLogger::Read(
29 int64 position, int size, uint8* data,
30 const media::DataSource::ReadCB& read_cb) {
31 VLOG(1) << "Read(" << position << ", " << size << ")";
32 data_source_->Read(position, size, data, base::Bind(
33 &LogAndRunReadCB, position, size, read_cb));
36 bool DataSourceLogger::GetSize(int64* size_out) {
37 bool success = data_source_->GetSize(size_out);
38 VLOG(1) << "GetSize() -> " << (success ? "true" : "false")
39 << ", " << *size_out;
40 return success;
43 bool DataSourceLogger::IsStreaming() {
44 if (streaming_) {
45 VLOG(1) << "IsStreaming() -> true (overridden)";
46 return true;
49 bool streaming = data_source_->IsStreaming();
50 VLOG(1) << "IsStreaming() -> " << (streaming ? "true" : "false");
51 return streaming;
54 void DataSourceLogger::SetBitrate(int bitrate) {
55 VLOG(1) << "SetBitrate(" << bitrate << ")";
56 data_source_->SetBitrate(bitrate);
59 DataSourceLogger::~DataSourceLogger() {}