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

Side by Side Diff: third_party/WebKit/Source/wtf/text/CString.cpp

Issue 2473093003: Fix up naming in CString. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 28
29 #include "wtf/ASCIICType.h" 29 #include "wtf/ASCIICType.h"
30 #include "wtf/allocator/PartitionAlloc.h" 30 #include "wtf/allocator/PartitionAlloc.h"
31 #include "wtf/allocator/Partitions.h" 31 #include "wtf/allocator/Partitions.h"
32 #include <string.h> 32 #include <string.h>
33 33
34 using namespace std; 34 using namespace std;
35 35
36 namespace WTF { 36 namespace WTF {
37 37
38 PassRefPtr<CStringBuffer> CStringBuffer::createUninitialized(size_t length, 38 PassRefPtr<CStringImpl> CStringImpl::createUninitialized(size_t length,
39 char*& data) { 39 char*& data) {
40 // TODO(esprehn): This doesn't account for the NUL. 40 // TODO(esprehn): This doesn't account for the NUL.
41 RELEASE_ASSERT(length < 41 RELEASE_ASSERT(length <
42 (numeric_limits<unsigned>::max() - sizeof(CStringBuffer))); 42 (numeric_limits<unsigned>::max() - sizeof(CStringImpl)));
43 43
44 // The +1 is for the terminating NUL character. 44 // The +1 is for the terminating NUL character.
45 size_t size = sizeof(CStringBuffer) + length + 1; 45 size_t size = sizeof(CStringImpl) + length + 1;
46 CStringBuffer* buffer = static_cast<CStringBuffer*>(Partitions::bufferMalloc( 46 CStringImpl* buffer = static_cast<CStringImpl*>(
47 size, WTF_HEAP_PROFILER_TYPE_NAME(CStringBuffer))); 47 Partitions::bufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringImpl)));
48 data = reinterpret_cast<char*>(buffer + 1); 48 data = reinterpret_cast<char*>(buffer + 1);
49 data[length] = '\0'; 49 data[length] = '\0';
50 return adoptRef(new (buffer) CStringBuffer(length)); 50 return adoptRef(new (buffer) CStringImpl(length));
51 } 51 }
52 52
53 void CStringBuffer::operator delete(void* ptr) { 53 void CStringImpl::operator delete(void* ptr) {
54 Partitions::bufferFree(ptr); 54 Partitions::bufferFree(ptr);
55 } 55 }
56 56
57 CString::CString(const char* chars, size_t length) { 57 CString::CString(const char* chars, size_t length) {
58 if (!chars) { 58 if (!chars) {
59 DCHECK_EQ(length, 0u); 59 DCHECK_EQ(length, 0u);
60 return; 60 return;
61 } 61 }
62 char* data; 62 char* data;
63 m_buffer = CStringBuffer::createUninitialized(length, data); 63 m_buffer = CStringImpl::createUninitialized(length, data);
64 memcpy(data, chars, length); 64 memcpy(data, chars, length);
65 } 65 }
66 66
67 bool CString::isSafeToSendToAnotherThread() const { 67 bool CString::isSafeToSendToAnotherThread() const {
68 return !m_buffer || m_buffer->hasOneRef(); 68 return !m_buffer || m_buffer->hasOneRef();
69 } 69 }
70 70
71 bool operator==(const CString& a, const CString& b) { 71 bool operator==(const CString& a, const CString& b) {
72 if (a.isNull() != b.isNull()) 72 if (a.isNull() != b.isNull())
73 return false; 73 return false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ostream.setf(std::ios::uppercase); 120 ostream.setf(std::ios::uppercase);
121 ostream << (character & 0xff); 121 ostream << (character & 0xff);
122 } 122 }
123 break; 123 break;
124 } 124 }
125 } 125 }
126 return ostream << '"'; 126 return ostream << '"';
127 } 127 }
128 128
129 } // namespace WTF 129 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/CString.h ('k') | third_party/WebKit/Source/wtf/text/CStringTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698