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

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 1076443002: Removed obsolete float_util.h as VS2013 supports standards well enough. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 5 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
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 "base/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
Mark Mentovai 2015/04/08 18:04:37 #include <cmath>
Mateusz Szymański 2015/04/09 07:32:51 Done.
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/leak_annotations.h" 12 #include "base/debug/leak_annotations.h"
13 #include "base/float_util.h"
14 #include "base/format_macros.h" 13 #include "base/format_macros.h"
15 #include "base/json/string_escape.h" 14 #include "base/json/string_escape.h"
16 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
17 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
18 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
19 #include "base/process/process_metrics.h" 18 #include "base/process/process_metrics.h"
20 #include "base/stl_util.h" 19 #include "base/stl_util.h"
21 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
23 #include "base/strings/string_tokenizer.h" 22 #include "base/strings/string_tokenizer.h"
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 StringAppendF(out, "%" PRIu64, static_cast<uint64>(value.as_uint)); 638 StringAppendF(out, "%" PRIu64, static_cast<uint64>(value.as_uint));
640 break; 639 break;
641 case TRACE_VALUE_TYPE_INT: 640 case TRACE_VALUE_TYPE_INT:
642 StringAppendF(out, "%" PRId64, static_cast<int64>(value.as_int)); 641 StringAppendF(out, "%" PRId64, static_cast<int64>(value.as_int));
643 break; 642 break;
644 case TRACE_VALUE_TYPE_DOUBLE: { 643 case TRACE_VALUE_TYPE_DOUBLE: {
645 // FIXME: base/json/json_writer.cc is using the same code, 644 // FIXME: base/json/json_writer.cc is using the same code,
646 // should be made into a common method. 645 // should be made into a common method.
647 std::string real; 646 std::string real;
648 double val = value.as_double; 647 double val = value.as_double;
649 if (IsFinite(val)) { 648 if (std::isfinite(val)) {
650 real = DoubleToString(val); 649 real = DoubleToString(val);
651 // Ensure that the number has a .0 if there's no decimal or 'e'. This 650 // Ensure that the number has a .0 if there's no decimal or 'e'. This
652 // makes sure that when we read the JSON back, it's interpreted as a 651 // makes sure that when we read the JSON back, it's interpreted as a
653 // real rather than an int. 652 // real rather than an int.
654 if (real.find('.') == std::string::npos && 653 if (real.find('.') == std::string::npos &&
655 real.find('e') == std::string::npos && 654 real.find('e') == std::string::npos &&
656 real.find('E') == std::string::npos) { 655 real.find('E') == std::string::npos) {
657 real.append(".0"); 656 real.append(".0");
658 } 657 }
659 // The JSON spec requires that non-integer values in the range (-1,1) 658 // The JSON spec requires that non-integer values in the range (-1,1)
660 // have a zero before the decimal point - ".52" is not valid, "0.52" is. 659 // have a zero before the decimal point - ".52" is not valid, "0.52" is.
661 if (real[0] == '.') { 660 if (real[0] == '.') {
662 real.insert(0, "0"); 661 real.insert(0, "0");
663 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') { 662 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') {
664 // "-.1" bad "-0.1" good 663 // "-.1" bad "-0.1" good
665 real.insert(1, "0"); 664 real.insert(1, "0");
666 } 665 }
667 } else if (IsNaN(val)){ 666 } else if (std::isnan(val)){
668 // The JSON spec doesn't allow NaN and Infinity (since these are 667 // The JSON spec doesn't allow NaN and Infinity (since these are
669 // objects in EcmaScript). Use strings instead. 668 // objects in EcmaScript). Use strings instead.
670 real = "\"NaN\""; 669 real = "\"NaN\"";
671 } else if (val < 0) { 670 } else if (val < 0) {
672 real = "\"-Infinity\""; 671 real = "\"-Infinity\"";
673 } else { 672 } else {
674 real = "\"Infinity\""; 673 real = "\"Infinity\"";
675 } 674 }
676 StringAppendF(out, "%s", real.c_str()); 675 StringAppendF(out, "%s", real.c_str());
677 break; 676 break;
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 } 2614 }
2616 2615
2617 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2616 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2618 if (*category_group_enabled_) { 2617 if (*category_group_enabled_) {
2619 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2618 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2620 name_, event_handle_); 2619 name_, event_handle_);
2621 } 2620 }
2622 } 2621 }
2623 2622
2624 } // namespace trace_event_internal 2623 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698