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

Side by Side Diff: samples/process.cc

Issue 1209403005: Let the second pass phantom callbacks run in a separate task on the foreground thread. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Run second pass callbacks synchronously when GC is forced. Created 5 years, 5 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 | « include/v8-util.h ('k') | samples/shell.cc » ('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 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
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
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 }
OLDNEW
« no previous file with comments | « include/v8-util.h ('k') | samples/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698