diff options
author | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
commit | 3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch) | |
tree | 7784b988ef1698cb6967ea1bdf07616237716c6c /base/ref_counted_memory.h | |
parent | efc8475837ec58186051f23bb03542620424f6ce (diff) | |
download | external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2 |
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used.
Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'base/ref_counted_memory.h')
-rw-r--r-- | base/ref_counted_memory.h | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/base/ref_counted_memory.h b/base/ref_counted_memory.h index eae7984..08400ec 100644 --- a/base/ref_counted_memory.h +++ b/base/ref_counted_memory.h @@ -1,9 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_REF_COUNTED_MEMORY_H_ #define BASE_REF_COUNTED_MEMORY_H_ +#pragma once #include <vector> @@ -26,8 +27,8 @@ class RefCountedMemory : public base::RefCountedThreadSafe<RefCountedMemory> { protected: friend class base::RefCountedThreadSafe<RefCountedMemory>; - - virtual ~RefCountedMemory() {} + RefCountedMemory(); + virtual ~RefCountedMemory(); }; // An implementation of RefCountedMemory, where the ref counting does not @@ -39,8 +40,8 @@ class RefCountedStaticMemory : public RefCountedMemory { RefCountedStaticMemory(const unsigned char* data, size_t length) : data_(data), length_(length) {} - virtual const unsigned char* front() const { return data_; } - virtual size_t size() const { return length_; } + virtual const unsigned char* front() const; + virtual size_t size() const; private: const unsigned char* data_; @@ -56,27 +57,22 @@ class RefCountedBytes : public RefCountedMemory { // Constructs a RefCountedBytes object by performing a swap. (To non // destructively build a RefCountedBytes, use the constructor that takes a // vector.) - static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy) { - RefCountedBytes* bytes = new RefCountedBytes; - bytes->data.swap(*to_destroy); - return bytes; - } + static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy); - RefCountedBytes() {} + RefCountedBytes(); // Constructs a RefCountedBytes object by _copying_ from |initializer|. - RefCountedBytes(const std::vector<unsigned char>& initializer) - : data(initializer) {} + RefCountedBytes(const std::vector<unsigned char>& initializer); - virtual const unsigned char* front() const { - // STL will assert if we do front() on an empty vector, but calling code - // expects a NULL. - return size() ? &data.front() : NULL; - } - virtual size_t size() const { return data.size(); } + virtual const unsigned char* front() const; + virtual size_t size() const; std::vector<unsigned char> data; + protected: + friend class base::RefCountedThreadSafe<RefCountedBytes>; + virtual ~RefCountedBytes(); + private: DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); }; |