OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/service.h" | 5 #include "vm/service.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 | 10 |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2823 static bool RespondWithMalformedObject(Isolate* isolate, | 2823 static bool RespondWithMalformedObject(Isolate* isolate, |
2824 JSONStream* js) { | 2824 JSONStream* js) { |
2825 JSONObject jsobj(js); | 2825 JSONObject jsobj(js); |
2826 jsobj.AddProperty("bart", "simpson"); | 2826 jsobj.AddProperty("bart", "simpson"); |
2827 return true; | 2827 return true; |
2828 } | 2828 } |
2829 | 2829 |
2830 | 2830 |
2831 static const MethodParameter* get_object_params[] = { | 2831 static const MethodParameter* get_object_params[] = { |
2832 ISOLATE_PARAMETER, | 2832 ISOLATE_PARAMETER, |
2833 new UIntParameter("offset", false), | |
2834 new UIntParameter("count", false), | |
2833 NULL, | 2835 NULL, |
2834 }; | 2836 }; |
2835 | 2837 |
2836 | 2838 |
2837 static bool GetObject(Isolate* isolate, JSONStream* js) { | 2839 static bool GetObject(Isolate* isolate, JSONStream* js) { |
2838 const char* id = js->LookupParam("objectId"); | 2840 const char* id = js->LookupParam("objectId"); |
2839 if (id == NULL) { | 2841 if (id == NULL) { |
2840 PrintMissingParamError(js, "objectId"); | 2842 PrintMissingParamError(js, "objectId"); |
2841 return true; | 2843 return true; |
2842 } | 2844 } |
2845 if (js->HasParam("offset")) { | |
2846 intptr_t value = UIntParameter::Parse(js->LookupParam("offset")); | |
2847 if (value < 0) { | |
2848 PrintInvalidParamError(js, "offset"); | |
2849 return true; | |
2850 } | |
2851 js->set_offset(value); | |
2852 } | |
2853 if (js->HasParam("count")) { | |
2854 intptr_t value = UIntParameter::Parse(js->LookupParam("count")); | |
2855 if (value < 1) { | |
Cutch
2015/10/14 17:58:09
Consider allowing queries of the container with a
turnidge
2015/10/14 18:02:42
Done.
| |
2856 PrintInvalidParamError(js, "count"); | |
2857 return true; | |
2858 } | |
2859 js->set_count(value); | |
2860 } | |
2843 | 2861 |
2844 // Handle heap objects. | 2862 // Handle heap objects. |
2845 ObjectIdRing::LookupResult lookup_result; | 2863 ObjectIdRing::LookupResult lookup_result; |
2846 const Object& obj = | 2864 const Object& obj = |
2847 Object::Handle(LookupHeapObject(isolate, id, &lookup_result)); | 2865 Object::Handle(LookupHeapObject(isolate, id, &lookup_result)); |
2848 if (obj.raw() != Object::sentinel().raw()) { | 2866 if (obj.raw() != Object::sentinel().raw()) { |
2849 // We found a heap object for this id. Return it. | 2867 // We found a heap object for this id. Return it. |
2850 obj.PrintJSON(js, false); | 2868 obj.PrintJSON(js, false); |
2851 return true; | 2869 return true; |
2852 } else if (lookup_result == ObjectIdRing::kCollected) { | 2870 } else if (lookup_result == ObjectIdRing::kCollected) { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3280 ServiceMethodDescriptor& method = service_methods_[i]; | 3298 ServiceMethodDescriptor& method = service_methods_[i]; |
3281 if (strcmp(method_name, method.name) == 0) { | 3299 if (strcmp(method_name, method.name) == 0) { |
3282 return &method; | 3300 return &method; |
3283 } | 3301 } |
3284 } | 3302 } |
3285 return NULL; | 3303 return NULL; |
3286 } | 3304 } |
3287 | 3305 |
3288 | 3306 |
3289 } // namespace dart | 3307 } // namespace dart |
OLD | NEW |