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

Side by Side Diff: chrome/test/automation/browser_proxy.cc

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/automation/browser_proxy.h" 5 #include "chrome/test/automation/browser_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; 598 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}";
599 599
600 *max_stop_time = 0; 600 *max_stop_time = 0;
601 *min_start_time = -1; 601 *min_start_time = -1;
602 if (!SendJSONRequest(kJSONCommand, timeout_ms, &json_response)) { 602 if (!SendJSONRequest(kJSONCommand, timeout_ms, &json_response)) {
603 // Older browser versions do not support GetInitialLoadTimes. 603 // Older browser versions do not support GetInitialLoadTimes.
604 // Fail gracefully and do not record them in this case. 604 // Fail gracefully and do not record them in this case.
605 return false; 605 return false;
606 } 606 }
607 std::string error; 607 std::string error;
608 base::JSONReader reader; 608 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(
609 scoped_ptr<Value> values(reader.ReadAndReturnError(json_response, true, 609 json_response, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error));
610 NULL, &error));
611 if (!error.empty() || values->GetType() != Value::TYPE_DICTIONARY) 610 if (!error.empty() || values->GetType() != Value::TYPE_DICTIONARY)
612 return false; 611 return false;
613 612
614 DictionaryValue* values_dict = static_cast<DictionaryValue*>(values.get()); 613 DictionaryValue* values_dict = static_cast<DictionaryValue*>(values.get());
615 614
616 Value* tabs_value; 615 Value* tabs_value;
617 if (!values_dict->Get("tabs", &tabs_value) || 616 if (!values_dict->Get("tabs", &tabs_value) ||
618 tabs_value->GetType() != Value::TYPE_LIST) 617 tabs_value->GetType() != Value::TYPE_LIST)
619 return false; 618 return false;
620 619
(...skipping 22 matching lines...) Expand all
643 if (i == 0) 642 if (i == 0)
644 *min_start_time = start_ms; 643 *min_start_time = start_ms;
645 644
646 *min_start_time = std::min(start_ms, *min_start_time); 645 *min_start_time = std::min(start_ms, *min_start_time);
647 *max_stop_time = std::max(stop_ms, *max_stop_time); 646 *max_stop_time = std::max(stop_ms, *max_stop_time);
648 stop_times->push_back(stop_ms); 647 stop_times->push_back(stop_ms);
649 } 648 }
650 std::sort(stop_times->begin(), stop_times->end()); 649 std::sort(stop_times->begin(), stop_times->end());
651 return true; 650 return true;
652 } 651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698