OLD | NEW |
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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 // External string wrapper so V8 can access the UTF16 string wrapped by | 87 // External string wrapper so V8 can access the UTF16 string wrapped by |
88 // ProxyResolverScriptData. | 88 // ProxyResolverScriptData. |
89 class V8ExternalStringFromScriptData | 89 class V8ExternalStringFromScriptData |
90 : public v8::String::ExternalStringResource { | 90 : public v8::String::ExternalStringResource { |
91 public: | 91 public: |
92 explicit V8ExternalStringFromScriptData( | 92 explicit V8ExternalStringFromScriptData( |
93 const scoped_refptr<ProxyResolverScriptData>& script_data) | 93 const scoped_refptr<ProxyResolverScriptData>& script_data) |
94 : script_data_(script_data) {} | 94 : script_data_(script_data) {} |
95 | 95 |
96 virtual const uint16_t* data() const OVERRIDE { | 96 virtual const uint16_t* data() const override { |
97 return reinterpret_cast<const uint16*>(script_data_->utf16().data()); | 97 return reinterpret_cast<const uint16*>(script_data_->utf16().data()); |
98 } | 98 } |
99 | 99 |
100 virtual size_t length() const OVERRIDE { | 100 virtual size_t length() const override { |
101 return script_data_->utf16().size(); | 101 return script_data_->utf16().size(); |
102 } | 102 } |
103 | 103 |
104 private: | 104 private: |
105 const scoped_refptr<ProxyResolverScriptData> script_data_; | 105 const scoped_refptr<ProxyResolverScriptData> script_data_; |
106 DISALLOW_COPY_AND_ASSIGN(V8ExternalStringFromScriptData); | 106 DISALLOW_COPY_AND_ASSIGN(V8ExternalStringFromScriptData); |
107 }; | 107 }; |
108 | 108 |
109 // External string wrapper so V8 can access a string literal. | 109 // External string wrapper so V8 can access a string literal. |
110 class V8ExternalASCIILiteral : public v8::String::ExternalAsciiStringResource { | 110 class V8ExternalASCIILiteral : public v8::String::ExternalAsciiStringResource { |
111 public: | 111 public: |
112 // |ascii| must be a NULL-terminated C string, and must remain valid | 112 // |ascii| must be a NULL-terminated C string, and must remain valid |
113 // throughout this object's lifetime. | 113 // throughout this object's lifetime. |
114 V8ExternalASCIILiteral(const char* ascii, size_t length) | 114 V8ExternalASCIILiteral(const char* ascii, size_t length) |
115 : ascii_(ascii), length_(length) { | 115 : ascii_(ascii), length_(length) { |
116 DCHECK(base::IsStringASCII(ascii)); | 116 DCHECK(base::IsStringASCII(ascii)); |
117 } | 117 } |
118 | 118 |
119 virtual const char* data() const OVERRIDE { | 119 virtual const char* data() const override { |
120 return ascii_; | 120 return ascii_; |
121 } | 121 } |
122 | 122 |
123 virtual size_t length() const OVERRIDE { | 123 virtual size_t length() const override { |
124 return length_; | 124 return length_; |
125 } | 125 } |
126 | 126 |
127 private: | 127 private: |
128 const char* ascii_; | 128 const char* ascii_; |
129 size_t length_; | 129 size_t length_; |
130 DISALLOW_COPY_AND_ASSIGN(V8ExternalASCIILiteral); | 130 DISALLOW_COPY_AND_ASSIGN(V8ExternalASCIILiteral); |
131 }; | 131 }; |
132 | 132 |
133 // When creating a v8::String from a C++ string we have two choices: create | 133 // When creating a v8::String from a C++ string we have two choices: create |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 return 0; | 802 return 0; |
803 | 803 |
804 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); | 804 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); |
805 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); | 805 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); |
806 v8::HeapStatistics heap_statistics; | 806 v8::HeapStatistics heap_statistics; |
807 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); | 807 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); |
808 return heap_statistics.used_heap_size(); | 808 return heap_statistics.used_heap_size(); |
809 } | 809 } |
810 | 810 |
811 } // namespace net | 811 } // namespace net |
OLD | NEW |