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

Side by Side Diff: src/inspector/V8Console.cpp

Issue 2339173004: Revert of [inspector] fixed all shorten-64-to-32 warnings (Closed)
Patch Set: Created 4 years, 3 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 | « src/inspector/StringUtil.cpp ('k') | src/inspector/V8Debugger.cpp » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 "src/inspector/V8Console.h" 5 #include "src/inspector/V8Console.h"
6 6
7 #include "src/base/macros.h" 7 #include "src/base/macros.h"
8 #include "src/inspector/InjectedScript.h" 8 #include "src/inspector/InjectedScript.h"
9 #include "src/inspector/InspectedContext.h" 9 #include "src/inspector/InspectedContext.h"
10 #include "src/inspector/StringUtil.h" 10 #include "src/inspector/StringUtil.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (mapValue->IsUndefined()) { 153 if (mapValue->IsUndefined()) {
154 v8::Local<v8::Map> map = v8::Map::New(m_isolate); 154 v8::Local<v8::Map> map = v8::Map::New(m_isolate);
155 if (!console->SetPrivate(m_context, privateKey, map).FromMaybe(false)) 155 if (!console->SetPrivate(m_context, privateKey, map).FromMaybe(false))
156 return v8::MaybeLocal<v8::Map>(); 156 return v8::MaybeLocal<v8::Map>();
157 return map; 157 return map;
158 } 158 }
159 return mapValue->IsMap() ? mapValue.As<v8::Map>() 159 return mapValue->IsMap() ? mapValue.As<v8::Map>()
160 : v8::MaybeLocal<v8::Map>(); 160 : v8::MaybeLocal<v8::Map>();
161 } 161 }
162 162
163 int32_t getIntFromMap(v8::Local<v8::Map> map, const String16& key, 163 int64_t getIntFromMap(v8::Local<v8::Map> map, const String16& key,
164 int32_t defaultValue) { 164 int64_t defaultValue) {
165 v8::Local<v8::String> v8Key = toV8String(m_isolate, key); 165 v8::Local<v8::String> v8Key = toV8String(m_isolate, key);
166 if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue; 166 if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue;
167 v8::Local<v8::Value> intValue; 167 v8::Local<v8::Value> intValue;
168 if (!map->Get(m_context, v8Key).ToLocal(&intValue)) return defaultValue; 168 if (!map->Get(m_context, v8Key).ToLocal(&intValue)) return defaultValue;
169 return static_cast<int32_t>(intValue.As<v8::Integer>()->Value()); 169 return intValue.As<v8::Integer>()->Value();
170 } 170 }
171 171
172 void setIntOnMap(v8::Local<v8::Map> map, const String16& key, int32_t value) { 172 void setIntOnMap(v8::Local<v8::Map> map, const String16& key, int64_t value) {
173 v8::Local<v8::String> v8Key = toV8String(m_isolate, key); 173 v8::Local<v8::String> v8Key = toV8String(m_isolate, key);
174 if (!map->Set(m_context, v8Key, v8::Integer::New(m_isolate, value)) 174 if (!map->Set(m_context, v8Key, v8::Integer::New(m_isolate, value))
175 .ToLocal(&map)) 175 .ToLocal(&map))
176 return; 176 return;
177 } 177 }
178 178
179 double getDoubleFromMap(v8::Local<v8::Map> map, const String16& key, 179 double getDoubleFromMap(v8::Local<v8::Map> map, const String16& key,
180 double defaultValue) { 180 double defaultValue) {
181 v8::Local<v8::String> v8Key = toV8String(m_isolate, key); 181 v8::Local<v8::String> v8Key = toV8String(m_isolate, key);
182 if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue; 182 if (!map->Has(m_context, v8Key).FromMaybe(false)) return defaultValue;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 V8StackTraceImpl::capture(nullptr, 0, 1); 346 V8StackTraceImpl::capture(nullptr, 0, 1);
347 if (stackTrace) 347 if (stackTrace)
348 identifier = toString16(stackTrace->topSourceURL()) + ":" + 348 identifier = toString16(stackTrace->topSourceURL()) + ":" +
349 String16::fromInteger(stackTrace->topLineNumber()); 349 String16::fromInteger(stackTrace->topLineNumber());
350 } else { 350 } else {
351 identifier = title + "@"; 351 identifier = title + "@";
352 } 352 }
353 353
354 v8::Local<v8::Map> countMap; 354 v8::Local<v8::Map> countMap;
355 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) return; 355 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) return;
356 int32_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; 356 int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1;
357 helper.setIntOnMap(countMap, identifier, count); 357 helper.setIntOnMap(countMap, identifier, count);
358 helper.reportCallWithArgument(ConsoleAPIType::kCount, 358 helper.reportCallWithArgument(ConsoleAPIType::kCount,
359 title + ": " + String16::fromInteger(count)); 359 title + ": " + String16::fromInteger(count));
360 } 360 }
361 361
362 void V8Console::assertCallback( 362 void V8Console::assertCallback(
363 const v8::FunctionCallbackInfo<v8::Value>& info) { 363 const v8::FunctionCallbackInfo<v8::Value>& info) {
364 ConsoleHelper helper(info); 364 ConsoleHelper helper(info);
365 if (helper.firstArgToBoolean(false)) return; 365 if (helper.firstArgToBoolean(false)) return;
366 366
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 v8::Isolate* isolate = info.GetIsolate(); 504 v8::Isolate* isolate = info.GetIsolate();
505 info.GetReturnValue().Set(v8::Array::New(isolate)); 505 info.GetReturnValue().Set(v8::Array::New(isolate));
506 506
507 ConsoleHelper helper(info); 507 ConsoleHelper helper(info);
508 v8::Local<v8::Object> obj; 508 v8::Local<v8::Object> obj;
509 if (!helper.firstArgAsObject().ToLocal(&obj)) return; 509 if (!helper.firstArgAsObject().ToLocal(&obj)) return;
510 v8::Local<v8::Array> names; 510 v8::Local<v8::Array> names;
511 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 511 v8::Local<v8::Context> context = isolate->GetCurrentContext();
512 if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return; 512 if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return;
513 v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length()); 513 v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length());
514 for (uint32_t i = 0; i < names->Length(); ++i) { 514 for (size_t i = 0; i < names->Length(); ++i) {
515 v8::Local<v8::Value> key; 515 v8::Local<v8::Value> key;
516 if (!names->Get(context, i).ToLocal(&key)) continue; 516 if (!names->Get(context, i).ToLocal(&key)) continue;
517 v8::Local<v8::Value> value; 517 v8::Local<v8::Value> value;
518 if (!obj->Get(context, key).ToLocal(&value)) continue; 518 if (!obj->Get(context, key).ToLocal(&value)) continue;
519 createDataProperty(context, values, i, value); 519 createDataProperty(context, values, i, value);
520 } 520 }
521 info.GetReturnValue().Set(values); 521 info.GetReturnValue().Set(values);
522 } 522 }
523 523
524 static void setFunctionBreakpoint(ConsoleHelper& helper, 524 static void setFunctionBreakpoint(ConsoleHelper& helper,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 v8::Local<v8::Object> global) 869 v8::Local<v8::Object> global)
870 : m_context(context), 870 : m_context(context),
871 m_commandLineAPI(commandLineAPI), 871 m_commandLineAPI(commandLineAPI),
872 m_global(global), 872 m_global(global),
873 m_installedMethods(v8::Set::New(context->GetIsolate())), 873 m_installedMethods(v8::Set::New(context->GetIsolate())),
874 m_cleanup(false) { 874 m_cleanup(false) {
875 v8::Local<v8::Array> names; 875 v8::Local<v8::Array> names;
876 if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return; 876 if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return;
877 v8::Local<v8::External> externalThis = 877 v8::Local<v8::External> externalThis =
878 v8::External::New(context->GetIsolate(), this); 878 v8::External::New(context->GetIsolate(), this);
879 for (uint32_t i = 0; i < names->Length(); ++i) { 879 for (size_t i = 0; i < names->Length(); ++i) {
880 v8::Local<v8::Value> name; 880 v8::Local<v8::Value> name;
881 if (!names->Get(context, i).ToLocal(&name) || !name->IsName()) continue; 881 if (!names->Get(context, i).ToLocal(&name) || !name->IsName()) continue;
882 if (m_global->Has(context, name).FromMaybe(true)) continue; 882 if (m_global->Has(context, name).FromMaybe(true)) continue;
883 if (!m_installedMethods->Add(context, name).ToLocal(&m_installedMethods)) 883 if (!m_installedMethods->Add(context, name).ToLocal(&m_installedMethods))
884 continue; 884 continue;
885 if (!m_global 885 if (!m_global
886 ->SetAccessor(context, v8::Local<v8::Name>::Cast(name), 886 ->SetAccessor(context, v8::Local<v8::Name>::Cast(name),
887 CommandLineAPIScope::accessorGetterCallback, 887 CommandLineAPIScope::accessorGetterCallback,
888 CommandLineAPIScope::accessorSetterCallback, 888 CommandLineAPIScope::accessorSetterCallback,
889 externalThis, v8::DEFAULT, v8::DontEnum) 889 externalThis, v8::DEFAULT, v8::DontEnum)
890 .FromMaybe(false)) { 890 .FromMaybe(false)) {
891 bool removed = m_installedMethods->Delete(context, name).FromMaybe(false); 891 bool removed = m_installedMethods->Delete(context, name).FromMaybe(false);
892 DCHECK(removed); 892 DCHECK(removed);
893 USE(removed); 893 USE(removed);
894 continue; 894 continue;
895 } 895 }
896 } 896 }
897 } 897 }
898 898
899 V8Console::CommandLineAPIScope::~CommandLineAPIScope() { 899 V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
900 m_cleanup = true; 900 m_cleanup = true;
901 v8::Local<v8::Array> names = m_installedMethods->AsArray(); 901 v8::Local<v8::Array> names = m_installedMethods->AsArray();
902 for (uint32_t i = 0; i < names->Length(); ++i) { 902 for (size_t i = 0; i < names->Length(); ++i) {
903 v8::Local<v8::Value> name; 903 v8::Local<v8::Value> name;
904 if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue; 904 if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName()) continue;
905 if (name->IsString()) { 905 if (name->IsString()) {
906 v8::Local<v8::Value> descriptor; 906 v8::Local<v8::Value> descriptor;
907 bool success = m_global 907 bool success = m_global
908 ->GetOwnPropertyDescriptor( 908 ->GetOwnPropertyDescriptor(
909 m_context, v8::Local<v8::String>::Cast(name)) 909 m_context, v8::Local<v8::String>::Cast(name))
910 .ToLocal(&descriptor); 910 .ToLocal(&descriptor);
911 DCHECK(success); 911 DCHECK(success);
912 USE(success); 912 USE(success);
913 } 913 }
914 } 914 }
915 } 915 }
916 916
917 } // namespace v8_inspector 917 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/StringUtil.cpp ('k') | src/inspector/V8Debugger.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698