Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: base/ref_counted_memory.h

Issue 3452030: FBTF: Moves code to the headers. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/message_pump.cc ('k') | base/ref_counted_memory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_REF_COUNTED_MEMORY_H_ 5 #ifndef BASE_REF_COUNTED_MEMORY_H_
6 #define BASE_REF_COUNTED_MEMORY_H_ 6 #define BASE_REF_COUNTED_MEMORY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 12
13 // TODO(erg): The contents of this file should be in a namespace. This would 13 // TODO(erg): The contents of this file should be in a namespace. This would
14 // require touching >100 files in chrome/ though. 14 // require touching >100 files in chrome/ though.
15 15
16 // A generic interface to memory. This object is reference counted because one 16 // A generic interface to memory. This object is reference counted because one
17 // of its two subclasses own the data they carry, and we need to have 17 // of its two subclasses own the data they carry, and we need to have
18 // heterogeneous containers of these two types of memory. 18 // heterogeneous containers of these two types of memory.
19 class RefCountedMemory : public base::RefCountedThreadSafe<RefCountedMemory> { 19 class RefCountedMemory : public base::RefCountedThreadSafe<RefCountedMemory> {
20 public: 20 public:
21 // Retrieves a pointer to the beginning of the data we point to. If the data 21 // Retrieves a pointer to the beginning of the data we point to. If the data
22 // is empty, this will return NULL. 22 // is empty, this will return NULL.
23 virtual const unsigned char* front() const = 0; 23 virtual const unsigned char* front() const = 0;
24 24
25 // Size of the memory pointed to. 25 // Size of the memory pointed to.
26 virtual size_t size() const = 0; 26 virtual size_t size() const = 0;
27 27
28 protected: 28 protected:
29 friend class base::RefCountedThreadSafe<RefCountedMemory>; 29 friend class base::RefCountedThreadSafe<RefCountedMemory>;
30 30 RefCountedMemory();
31 virtual ~RefCountedMemory() {} 31 virtual ~RefCountedMemory();
32 }; 32 };
33 33
34 // An implementation of RefCountedMemory, where the ref counting does not 34 // An implementation of RefCountedMemory, where the ref counting does not
35 // matter. 35 // matter.
36 class RefCountedStaticMemory : public RefCountedMemory { 36 class RefCountedStaticMemory : public RefCountedMemory {
37 public: 37 public:
38 RefCountedStaticMemory() 38 RefCountedStaticMemory()
39 : data_(NULL), length_(0) {} 39 : data_(NULL), length_(0) {}
40 RefCountedStaticMemory(const unsigned char* data, size_t length) 40 RefCountedStaticMemory(const unsigned char* data, size_t length)
41 : data_(data), length_(length) {} 41 : data_(data), length_(length) {}
(...skipping 29 matching lines...) Expand all
71 71
72 protected: 72 protected:
73 friend class base::RefCountedThreadSafe<RefCountedBytes>; 73 friend class base::RefCountedThreadSafe<RefCountedBytes>;
74 virtual ~RefCountedBytes(); 74 virtual ~RefCountedBytes();
75 75
76 private: 76 private:
77 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); 77 DISALLOW_COPY_AND_ASSIGN(RefCountedBytes);
78 }; 78 };
79 79
80 #endif // BASE_REF_COUNTED_MEMORY_H_ 80 #endif // BASE_REF_COUNTED_MEMORY_H_
OLDNEW
« no previous file with comments | « base/message_pump.cc ('k') | base/ref_counted_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698