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

Side by Side Diff: net/proxy/proxy_resolver_v8.cc

Issue 1223983002: Move WriteInto to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « net/disk_cache/blockfile/entry_impl_v3.cc ('k') | net/quic/crypto/channel_id_chromium.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/proxy/proxy_resolver_v8.h" 5 #include "net/proxy/proxy_resolver_v8.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdio> 8 #include <cstdio>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // For small strings it is better to just make a copy, whereas for large 133 // For small strings it is better to just make a copy, whereas for large
134 // strings there are savings by sharing the storage. This number identifies 134 // strings there are savings by sharing the storage. This number identifies
135 // the cutoff length for when to start wrapping rather than creating copies. 135 // the cutoff length for when to start wrapping rather than creating copies.
136 const size_t kMaxStringBytesForCopy = 256; 136 const size_t kMaxStringBytesForCopy = 256;
137 137
138 // Converts a V8 String to a UTF8 std::string. 138 // Converts a V8 String to a UTF8 std::string.
139 std::string V8StringToUTF8(v8::Local<v8::String> s) { 139 std::string V8StringToUTF8(v8::Local<v8::String> s) {
140 int len = s->Length(); 140 int len = s->Length();
141 std::string result; 141 std::string result;
142 if (len > 0) 142 if (len > 0)
143 s->WriteUtf8(WriteInto(&result, len + 1)); 143 s->WriteUtf8(base::WriteInto(&result, len + 1));
144 return result; 144 return result;
145 } 145 }
146 146
147 // Converts a V8 String to a UTF16 base::string16. 147 // Converts a V8 String to a UTF16 base::string16.
148 base::string16 V8StringToUTF16(v8::Local<v8::String> s) { 148 base::string16 V8StringToUTF16(v8::Local<v8::String> s) {
149 int len = s->Length(); 149 int len = s->Length();
150 base::string16 result; 150 base::string16 result;
151 // Note that the reinterpret cast is because on Windows string16 is an alias 151 // Note that the reinterpret cast is because on Windows string16 is an alias
152 // to wstring, and hence has character type wchar_t not uint16_t. 152 // to wstring, and hence has character type wchar_t not uint16_t.
153 if (len > 0) 153 if (len > 0) {
154 s->Write(reinterpret_cast<uint16_t*>(WriteInto(&result, len + 1)), 0, len); 154 s->Write(reinterpret_cast<uint16_t*>(base::WriteInto(&result, len + 1)), 0,
155 len);
156 }
155 return result; 157 return result;
156 } 158 }
157 159
158 // Converts an ASCII std::string to a V8 string. 160 // Converts an ASCII std::string to a V8 string.
159 v8::Local<v8::String> ASCIIStringToV8String(v8::Isolate* isolate, 161 v8::Local<v8::String> ASCIIStringToV8String(v8::Isolate* isolate,
160 const std::string& s) { 162 const std::string& s) {
161 DCHECK(base::IsStringASCII(s)); 163 DCHECK(base::IsStringASCII(s));
162 return v8::String::NewFromUtf8(isolate, s.data(), v8::NewStringType::kNormal, 164 return v8::String::NewFromUtf8(isolate, s.data(), v8::NewStringType::kNormal,
163 s.size()).ToLocalChecked(); 165 s.size()).ToLocalChecked();
164 } 166 }
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 return 0; 879 return 0;
878 880
879 v8::Locker locked(isolate); 881 v8::Locker locked(isolate);
880 v8::Isolate::Scope isolate_scope(isolate); 882 v8::Isolate::Scope isolate_scope(isolate);
881 v8::HeapStatistics heap_statistics; 883 v8::HeapStatistics heap_statistics;
882 isolate->GetHeapStatistics(&heap_statistics); 884 isolate->GetHeapStatistics(&heap_statistics);
883 return heap_statistics.used_heap_size(); 885 return heap_statistics.used_heap_size();
884 } 886 }
885 887
886 } // namespace net 888 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/entry_impl_v3.cc ('k') | net/quic/crypto/channel_id_chromium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698