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

Side by Side Diff: samples/process.cc

Issue 321123002: Make presubmit script happy again. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « include/v8-util.h ('k') | src/base/build_config.h » ('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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 const string& host, 567 const string& host,
568 const string& user_agent) 568 const string& user_agent)
569 : path_(path), 569 : path_(path),
570 referrer_(referrer), 570 referrer_(referrer),
571 host_(host), 571 host_(host),
572 user_agent_(user_agent) { } 572 user_agent_(user_agent) { }
573 573
574 574
575 void ParseOptions(int argc, 575 void ParseOptions(int argc,
576 char* argv[], 576 char* argv[],
577 map<string, string>& options, 577 map<string, string>* options,
578 string* file) { 578 string* file) {
579 for (int i = 1; i < argc; i++) { 579 for (int i = 1; i < argc; i++) {
580 string arg = argv[i]; 580 string arg = argv[i];
581 size_t index = arg.find('=', 0); 581 size_t index = arg.find('=', 0);
582 if (index == string::npos) { 582 if (index == string::npos) {
583 *file = arg; 583 *file = arg;
584 } else { 584 } else {
585 string key = arg.substr(0, index); 585 string key = arg.substr(0, index);
586 string value = arg.substr(index+1); 586 string value = arg.substr(index+1);
587 options[key] = value; 587 (*options)[key] = value;
588 } 588 }
589 } 589 }
590 } 590 }
591 591
592 592
593 // Reads a file into a v8 string. 593 // Reads a file into a v8 string.
594 Handle<String> ReadFile(Isolate* isolate, const string& name) { 594 Handle<String> ReadFile(Isolate* isolate, const string& name) {
595 FILE* file = fopen(name.c_str(), "rb"); 595 FILE* file = fopen(name.c_str(), "rb");
596 if (file == NULL) return Handle<String>(); 596 if (file == NULL) return Handle<String>();
597 597
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 pair<string, string> entry = *i; 639 pair<string, string> entry = *i;
640 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str()); 640 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str());
641 } 641 }
642 } 642 }
643 643
644 644
645 int main(int argc, char* argv[]) { 645 int main(int argc, char* argv[]) {
646 v8::V8::InitializeICU(); 646 v8::V8::InitializeICU();
647 map<string, string> options; 647 map<string, string> options;
648 string file; 648 string file;
649 ParseOptions(argc, argv, options, &file); 649 ParseOptions(argc, argv, &options, &file);
650 if (file.empty()) { 650 if (file.empty()) {
651 fprintf(stderr, "No script was specified.\n"); 651 fprintf(stderr, "No script was specified.\n");
652 return 1; 652 return 1;
653 } 653 }
654 Isolate* isolate = Isolate::New(); 654 Isolate* isolate = Isolate::New();
655 Isolate::Scope isolate_scope(isolate); 655 Isolate::Scope isolate_scope(isolate);
656 HandleScope scope(isolate); 656 HandleScope scope(isolate);
657 Handle<String> source = ReadFile(isolate, file); 657 Handle<String> source = ReadFile(isolate, file);
658 if (source.IsEmpty()) { 658 if (source.IsEmpty()) {
659 fprintf(stderr, "Error reading '%s'.\n", file.c_str()); 659 fprintf(stderr, "Error reading '%s'.\n", file.c_str());
660 return 1; 660 return 1;
661 } 661 }
662 JsHttpRequestProcessor processor(isolate, source); 662 JsHttpRequestProcessor processor(isolate, source);
663 map<string, string> output; 663 map<string, string> output;
664 if (!processor.Initialize(&options, &output)) { 664 if (!processor.Initialize(&options, &output)) {
665 fprintf(stderr, "Error initializing processor.\n"); 665 fprintf(stderr, "Error initializing processor.\n");
666 return 1; 666 return 1;
667 } 667 }
668 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) 668 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests))
669 return 1; 669 return 1;
670 PrintMap(&output); 670 PrintMap(&output);
671 } 671 }
OLDNEW
« no previous file with comments | « include/v8-util.h ('k') | src/base/build_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698