OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "SkDmuxWStream.h" | |
9 | |
10 SkDmuxWStream::SkDmuxWStream(SkWStream* const streamArray[], size_t count) | |
11 : fWStreams(streamArray, static_cast<int>(count)), fBytesWritten(0) {} | |
12 | |
13 SkDmuxWStream::~SkDmuxWStream() { | |
14 for (int i = 0; i < fWStreams.count(); ++i) { | |
15 fWStreams[i]->flush(); | |
16 } | |
17 } | |
18 | |
19 bool SkDmuxWStream::write(const void* buffer, size_t size) { | |
20 for (int i = 0; i < fWStreams.count(); ++i) { | |
21 if (!fWStreams[i]->write(buffer, size)) { | |
22 return false; | |
23 } | |
24 } | |
25 fBytesWritten += size; | |
26 return true; | |
27 } | |
28 | |
29 void SkDmuxWStream::newline() { | |
30 for (int i = 0; i < fWStreams.count(); ++i) { | |
31 fWStreams[i]->newline(); | |
32 } | |
33 fBytesWritten += 1; // This may be a lie. | |
34 } | |
35 | |
36 void SkDmuxWStream::flush() { | |
37 for (int i = 0; i < fWStreams.count(); ++i) { | |
38 fWStreams[i]->flush(); | |
39 } | |
40 } | |
41 | |
42 size_t SkDmuxWStream::bytesWritten() const { return fBytesWritten; } | |
OLD | NEW |