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

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: Added missing includes everywhere. 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>
8 #include <cmath>
8 9
9 #include "base/base_switches.h" 10 #include "base/base_switches.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/debug/leak_annotations.h" 13 #include "base/debug/leak_annotations.h"
13 #include "base/float_util.h"
14 #include "base/format_macros.h" 14 #include "base/format_macros.h"
15 #include "base/json/string_escape.h" 15 #include "base/json/string_escape.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/process/process_metrics.h" 19 #include "base/process/process_metrics.h"
20 #include "base/stl_util.h" 20 #include "base/stl_util.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/strings/string_tokenizer.h" 23 #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)); 639 StringAppendF(out, "%" PRIu64, static_cast<uint64>(value.as_uint));
640 break; 640 break;
641 case TRACE_VALUE_TYPE_INT: 641 case TRACE_VALUE_TYPE_INT:
642 StringAppendF(out, "%" PRId64, static_cast<int64>(value.as_int)); 642 StringAppendF(out, "%" PRId64, static_cast<int64>(value.as_int));
643 break; 643 break;
644 case TRACE_VALUE_TYPE_DOUBLE: { 644 case TRACE_VALUE_TYPE_DOUBLE: {
645 // FIXME: base/json/json_writer.cc is using the same code, 645 // FIXME: base/json/json_writer.cc is using the same code,
646 // should be made into a common method. 646 // should be made into a common method.
647 std::string real; 647 std::string real;
648 double val = value.as_double; 648 double val = value.as_double;
649 if (IsFinite(val)) { 649 if (std::isfinite(val)) {
650 real = DoubleToString(val); 650 real = DoubleToString(val);
651 // Ensure that the number has a .0 if there's no decimal or 'e'. This 651 // 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 652 // makes sure that when we read the JSON back, it's interpreted as a
653 // real rather than an int. 653 // real rather than an int.
654 if (real.find('.') == std::string::npos && 654 if (real.find('.') == std::string::npos &&
655 real.find('e') == std::string::npos && 655 real.find('e') == std::string::npos &&
656 real.find('E') == std::string::npos) { 656 real.find('E') == std::string::npos) {
657 real.append(".0"); 657 real.append(".0");
658 } 658 }
659 // The JSON spec requires that non-integer values in the range (-1,1) 659 // 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. 660 // have a zero before the decimal point - ".52" is not valid, "0.52" is.
661 if (real[0] == '.') { 661 if (real[0] == '.') {
662 real.insert(0, "0"); 662 real.insert(0, "0");
663 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') { 663 } else if (real.length() > 1 && real[0] == '-' && real[1] == '.') {
664 // "-.1" bad "-0.1" good 664 // "-.1" bad "-0.1" good
665 real.insert(1, "0"); 665 real.insert(1, "0");
666 } 666 }
667 } else if (IsNaN(val)){ 667 } else if (std::isnan(val)){
668 // The JSON spec doesn't allow NaN and Infinity (since these are 668 // The JSON spec doesn't allow NaN and Infinity (since these are
669 // objects in EcmaScript). Use strings instead. 669 // objects in EcmaScript). Use strings instead.
670 real = "\"NaN\""; 670 real = "\"NaN\"";
671 } else if (val < 0) { 671 } else if (val < 0) {
672 real = "\"-Infinity\""; 672 real = "\"-Infinity\"";
673 } else { 673 } else {
674 real = "\"Infinity\""; 674 real = "\"Infinity\"";
675 } 675 }
676 StringAppendF(out, "%s", real.c_str()); 676 StringAppendF(out, "%s", real.c_str());
677 break; 677 break;
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 } 2615 }
2616 2616
2617 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2617 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2618 if (*category_group_enabled_) { 2618 if (*category_group_enabled_) {
2619 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2619 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2620 name_, event_handle_); 2620 name_, event_handle_);
2621 } 2621 }
2622 } 2622 }
2623 2623
2624 } // namespace trace_event_internal 2624 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/time/time.cc ('k') | base/values.cc » ('j') | chrome/browser/speech/tts_controller_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698