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

Side by Side Diff: base/value_conversions.cc

Issue 10545104: Refactor chrome.alarms interface to support absolute alarm deadlines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r141780 Created 8 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 | « base/value_conversions.h ('k') | chrome/browser/extensions/api/alarms/alarm_manager.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 (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/value_conversions.h" 5 #include "base/value_conversions.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 10 matching lines...) Expand all
21 std::string str; 21 std::string str;
22 if (!value.GetAsString(&str)) 22 if (!value.GetAsString(&str))
23 return false; 23 return false;
24 if (file_path) 24 if (file_path)
25 *file_path = FilePath::FromUTF8Unsafe(str); 25 *file_path = FilePath::FromUTF8Unsafe(str);
26 return true; 26 return true;
27 } 27 }
28 28
29 // |Value| does not support 64-bit integers, and doubles do not have enough 29 // |Value| does not support 64-bit integers, and doubles do not have enough
30 // precision, so we store the 64-bit time value as a string instead. 30 // precision, so we store the 64-bit time value as a string instead.
31 StringValue* CreateTimeValue(const Time& time) { 31 StringValue* CreateTimeDeltaValue(const TimeDelta& time) {
32 std::string string_value = base::Int64ToString(time.ToInternalValue()); 32 std::string string_value = base::Int64ToString(time.ToInternalValue());
33 return new StringValue(string_value); 33 return new StringValue(string_value);
34 } 34 }
35 35
36 bool GetValueAsTime(const Value& value, Time* time) { 36 bool GetValueAsTimeDelta(const Value& value, TimeDelta* time) {
37 std::string str; 37 std::string str;
38 int64 int_value; 38 int64 int_value;
39 if (!value.GetAsString(&str) || !base::StringToInt64(str, &int_value)) 39 if (!value.GetAsString(&str) || !base::StringToInt64(str, &int_value))
40 return false; 40 return false;
41 if (time) 41 if (time)
42 *time = base::Time::FromInternalValue(int_value); 42 *time = TimeDelta::FromInternalValue(int_value);
43 return true; 43 return true;
44 } 44 }
45 45
46 } // namespace base 46 } // namespace base
OLDNEW
« no previous file with comments | « base/value_conversions.h ('k') | chrome/browser/extensions/api/alarms/alarm_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698