| 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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 jsobj->AddProperty("text", js->LookupParam("text")); | 923 jsobj->AddProperty("text", js->LookupParam("text")); |
| 924 } | 924 } |
| 925 return true; | 925 return true; |
| 926 } | 926 } |
| 927 | 927 |
| 928 | 928 |
| 929 void Service::SendEchoEvent(Isolate* isolate, const char* text) { | 929 void Service::SendEchoEvent(Isolate* isolate, const char* text) { |
| 930 JSONStream js; | 930 JSONStream js; |
| 931 { | 931 { |
| 932 JSONObject jsobj(&js); | 932 JSONObject jsobj(&js); |
| 933 jsobj.AddProperty("jsonrpc", "2.0"); |
| 934 jsobj.AddProperty("method", "streamNotify"); |
| 933 { | 935 { |
| 934 JSONObject event(&jsobj, "event"); | 936 JSONObject params(&jsobj, "params"); |
| 935 event.AddProperty("type", "Event"); | 937 params.AddProperty("streamId", echo_stream.id()); |
| 936 event.AddProperty("kind", "_Echo"); | 938 { |
| 937 event.AddProperty("isolate", isolate); | 939 JSONObject event(¶ms, "event"); |
| 938 if (text != NULL) { | 940 event.AddProperty("type", "Event"); |
| 939 event.AddProperty("text", text); | 941 event.AddProperty("kind", "_Echo"); |
| 942 event.AddProperty("isolate", isolate); |
| 943 if (text != NULL) { |
| 944 event.AddProperty("text", text); |
| 945 } |
| 940 } | 946 } |
| 941 } | 947 } |
| 942 jsobj.AddProperty("streamId", echo_stream.id()); | |
| 943 } | 948 } |
| 944 const String& message = String::Handle(String::New(js.ToCString())); | 949 const String& message = String::Handle(String::New(js.ToCString())); |
| 945 uint8_t data[] = {0, 128, 255}; | 950 uint8_t data[] = {0, 128, 255}; |
| 946 SendEventWithData(echo_stream.id(), "_Echo", message, data, sizeof(data)); | 951 SendEventWithData(echo_stream.id(), "_Echo", message, data, sizeof(data)); |
| 947 } | 952 } |
| 948 | 953 |
| 949 | 954 |
| 950 static bool TriggerEchoEvent(Isolate* isolate, JSONStream* js) { | 955 static bool TriggerEchoEvent(Isolate* isolate, JSONStream* js) { |
| 951 if (Service::echo_stream.enabled()) { | 956 if (Service::echo_stream.enabled()) { |
| 952 Service::SendEchoEvent(isolate, js->LookupParam("text")); | 957 Service::SendEchoEvent(isolate, js->LookupParam("text")); |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2466 | 2471 |
| 2467 // Chrome crashes receiving a single tens-of-megabytes blob, so send the | 2472 // Chrome crashes receiving a single tens-of-megabytes blob, so send the |
| 2468 // snapshot in megabyte-sized chunks instead. | 2473 // snapshot in megabyte-sized chunks instead. |
| 2469 const intptr_t kChunkSize = 1 * MB; | 2474 const intptr_t kChunkSize = 1 * MB; |
| 2470 intptr_t num_chunks = | 2475 intptr_t num_chunks = |
| 2471 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; | 2476 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; |
| 2472 for (intptr_t i = 0; i < num_chunks; i++) { | 2477 for (intptr_t i = 0; i < num_chunks; i++) { |
| 2473 JSONStream js; | 2478 JSONStream js; |
| 2474 { | 2479 { |
| 2475 JSONObject jsobj(&js); | 2480 JSONObject jsobj(&js); |
| 2481 jsobj.AddProperty("jsonrpc", "2.0"); |
| 2482 jsobj.AddProperty("method", "streamNotify"); |
| 2476 { | 2483 { |
| 2477 JSONObject event(&jsobj, "event"); | 2484 JSONObject params(&jsobj, "params"); |
| 2478 event.AddProperty("type", "Event"); | 2485 params.AddProperty("streamId", graph_stream.id()); |
| 2479 event.AddProperty("kind", "_Graph"); | 2486 { |
| 2480 event.AddProperty("isolate", isolate); | 2487 JSONObject event(¶ms, "event"); |
| 2488 event.AddProperty("type", "Event"); |
| 2489 event.AddProperty("kind", "_Graph"); |
| 2490 event.AddProperty("isolate", isolate); |
| 2481 | 2491 |
| 2482 event.AddProperty("chunkIndex", i); | 2492 event.AddProperty("chunkIndex", i); |
| 2483 event.AddProperty("chunkCount", num_chunks); | 2493 event.AddProperty("chunkCount", num_chunks); |
| 2484 event.AddProperty("nodeCount", node_count); | 2494 event.AddProperty("nodeCount", node_count); |
| 2495 } |
| 2485 } | 2496 } |
| 2486 jsobj.AddProperty("streamId", graph_stream.id()); | |
| 2487 } | 2497 } |
| 2488 | 2498 |
| 2489 const String& message = String::Handle(String::New(js.ToCString())); | 2499 const String& message = String::Handle(String::New(js.ToCString())); |
| 2490 | 2500 |
| 2491 uint8_t* chunk_start = buffer + (i * kChunkSize); | 2501 uint8_t* chunk_start = buffer + (i * kChunkSize); |
| 2492 intptr_t chunk_size = (i + 1 == num_chunks) | 2502 intptr_t chunk_size = (i + 1 == num_chunks) |
| 2493 ? stream.bytes_written() - (i * kChunkSize) | 2503 ? stream.bytes_written() - (i * kChunkSize) |
| 2494 : kChunkSize; | 2504 : kChunkSize; |
| 2495 | 2505 |
| 2496 SendEventWithData(graph_stream.id(), "_Graph", message, | 2506 SendEventWithData(graph_stream.id(), "_Graph", message, |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3069 ServiceMethodDescriptor& method = service_methods_[i]; | 3079 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3070 if (strcmp(method_name, method.name) == 0) { | 3080 if (strcmp(method_name, method.name) == 0) { |
| 3071 return &method; | 3081 return &method; |
| 3072 } | 3082 } |
| 3073 } | 3083 } |
| 3074 return NULL; | 3084 return NULL; |
| 3075 } | 3085 } |
| 3076 | 3086 |
| 3077 | 3087 |
| 3078 } // namespace dart | 3088 } // namespace dart |
| OLD | NEW |