OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 StringHttpRequest kSampleRequests[kSampleSize] = { | 659 StringHttpRequest kSampleRequests[kSampleSize] = { |
660 StringHttpRequest("/process.cc", "localhost", "google.com", "firefox"), | 660 StringHttpRequest("/process.cc", "localhost", "google.com", "firefox"), |
661 StringHttpRequest("/", "localhost", "google.net", "firefox"), | 661 StringHttpRequest("/", "localhost", "google.net", "firefox"), |
662 StringHttpRequest("/", "localhost", "google.org", "safari"), | 662 StringHttpRequest("/", "localhost", "google.org", "safari"), |
663 StringHttpRequest("/", "localhost", "yahoo.com", "ie"), | 663 StringHttpRequest("/", "localhost", "yahoo.com", "ie"), |
664 StringHttpRequest("/", "localhost", "yahoo.com", "safari"), | 664 StringHttpRequest("/", "localhost", "yahoo.com", "safari"), |
665 StringHttpRequest("/", "localhost", "yahoo.com", "firefox") | 665 StringHttpRequest("/", "localhost", "yahoo.com", "firefox") |
666 }; | 666 }; |
667 | 667 |
668 | 668 |
669 bool ProcessEntries(HttpRequestProcessor* processor, int count, | 669 bool ProcessEntries(v8::Platform* platform, HttpRequestProcessor* processor, |
670 StringHttpRequest* reqs) { | 670 int count, StringHttpRequest* reqs) { |
671 for (int i = 0; i < count; i++) { | 671 for (int i = 0; i < count; i++) { |
672 if (!processor->Process(&reqs[i])) | 672 bool result = processor->Process(&reqs[i]); |
673 return false; | 673 while (v8::platform::PumpMessageLoop(platform, Isolate::GetCurrent())) |
| 674 continue; |
| 675 if (!result) return false; |
674 } | 676 } |
675 return true; | 677 return true; |
676 } | 678 } |
677 | 679 |
678 | 680 |
679 void PrintMap(map<string, string>* m) { | 681 void PrintMap(map<string, string>* m) { |
680 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) { | 682 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) { |
681 pair<string, string> entry = *i; | 683 pair<string, string> entry = *i; |
682 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str()); | 684 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str()); |
683 } | 685 } |
(...skipping 22 matching lines...) Expand all Loading... |
706 if (!ReadFile(isolate, file).ToLocal(&source)) { | 708 if (!ReadFile(isolate, file).ToLocal(&source)) { |
707 fprintf(stderr, "Error reading '%s'.\n", file.c_str()); | 709 fprintf(stderr, "Error reading '%s'.\n", file.c_str()); |
708 return 1; | 710 return 1; |
709 } | 711 } |
710 JsHttpRequestProcessor processor(isolate, source); | 712 JsHttpRequestProcessor processor(isolate, source); |
711 map<string, string> output; | 713 map<string, string> output; |
712 if (!processor.Initialize(&options, &output)) { | 714 if (!processor.Initialize(&options, &output)) { |
713 fprintf(stderr, "Error initializing processor.\n"); | 715 fprintf(stderr, "Error initializing processor.\n"); |
714 return 1; | 716 return 1; |
715 } | 717 } |
716 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) | 718 if (!ProcessEntries(platform, &processor, kSampleSize, kSampleRequests)) |
717 return 1; | 719 return 1; |
718 PrintMap(&output); | 720 PrintMap(&output); |
719 } | 721 } |
OLD | NEW |