OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 "base/ref_counted_memory.h" |
| 6 |
| 7 const unsigned char* RefCountedStaticMemory::front() const { |
| 8 return data_; |
| 9 } |
| 10 |
| 11 size_t RefCountedStaticMemory::size() const { |
| 12 return length_; |
| 13 } |
| 14 |
| 15 RefCountedBytes* RefCountedBytes::TakeVector( |
| 16 std::vector<unsigned char>* to_destroy) { |
| 17 RefCountedBytes* bytes = new RefCountedBytes; |
| 18 bytes->data.swap(*to_destroy); |
| 19 return bytes; |
| 20 } |
| 21 |
| 22 RefCountedBytes::RefCountedBytes() { |
| 23 } |
| 24 |
| 25 RefCountedBytes::RefCountedBytes(const std::vector<unsigned char>& initializer) |
| 26 : data(initializer) { |
| 27 } |
| 28 |
| 29 const unsigned char* RefCountedBytes::front() const { |
| 30 // STL will assert if we do front() on an empty vector, but calling code |
| 31 // expects a NULL. |
| 32 return size() ? &data.front() : NULL; |
| 33 } |
| 34 |
| 35 size_t RefCountedBytes::size() const { |
| 36 return data.size(); |
| 37 } |
OLD | NEW |