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

Side by Side Diff: chrome/browser/extensions/extension_history_api.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/extensions/extension_history_api.h" 5 #include "chrome/browser/extensions/extension_history_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 13 matching lines...) Expand all
24 24
25 double MilliSecondsFromTime(const base::Time& time) { 25 double MilliSecondsFromTime(const base::Time& time) {
26 return 1000 * time.ToDoubleT(); 26 return 1000 * time.ToDoubleT();
27 } 27 }
28 28
29 void GetHistoryItemDictionary(const history::URLRow& row, 29 void GetHistoryItemDictionary(const history::URLRow& row,
30 DictionaryValue* value) { 30 DictionaryValue* value) {
31 value->SetString(keys::kIdKey, base::Int64ToString(row.id())); 31 value->SetString(keys::kIdKey, base::Int64ToString(row.id()));
32 value->SetString(keys::kUrlKey, row.url().spec()); 32 value->SetString(keys::kUrlKey, row.url().spec());
33 value->SetString(keys::kTitleKey, row.title()); 33 value->SetString(keys::kTitleKey, row.title());
34 value->SetReal(keys::kLastVisitdKey, MilliSecondsFromTime(row.last_visit())); 34 value->SetDouble(keys::kLastVisitdKey,
35 MilliSecondsFromTime(row.last_visit()));
35 value->SetInteger(keys::kTypedCountKey, row.typed_count()); 36 value->SetInteger(keys::kTypedCountKey, row.typed_count());
36 value->SetInteger(keys::kVisitCountKey, row.visit_count()); 37 value->SetInteger(keys::kVisitCountKey, row.visit_count());
37 } 38 }
38 39
39 void AddHistoryNode(const history::URLRow& row, ListValue* list) { 40 void AddHistoryNode(const history::URLRow& row, ListValue* list) {
40 DictionaryValue* dict = new DictionaryValue(); 41 DictionaryValue* dict = new DictionaryValue();
41 GetHistoryItemDictionary(row, dict); 42 GetHistoryItemDictionary(row, dict);
42 list->Append(dict); 43 list->Append(dict);
43 } 44 }
44 45
45 void GetVisitInfoDictionary(const history::VisitRow& row, 46 void GetVisitInfoDictionary(const history::VisitRow& row,
46 DictionaryValue* value) { 47 DictionaryValue* value) {
47 value->SetString(keys::kIdKey, base::Int64ToString(row.url_id)); 48 value->SetString(keys::kIdKey, base::Int64ToString(row.url_id));
48 value->SetString(keys::kVisitId, base::Int64ToString(row.visit_id)); 49 value->SetString(keys::kVisitId, base::Int64ToString(row.visit_id));
49 value->SetReal(keys::kVisitTime, MilliSecondsFromTime(row.visit_time)); 50 value->SetDouble(keys::kVisitTime, MilliSecondsFromTime(row.visit_time));
50 value->SetString(keys::kReferringVisitId, 51 value->SetString(keys::kReferringVisitId,
51 base::Int64ToString(row.referring_visit)); 52 base::Int64ToString(row.referring_visit));
52 53
53 const char* trans = PageTransition::CoreTransitionString(row.transition); 54 const char* trans = PageTransition::CoreTransitionString(row.transition);
54 DCHECK(trans) << "Invalid transition."; 55 DCHECK(trans) << "Invalid transition.";
55 value->SetString(keys::kTransition, trans); 56 value->SetString(keys::kTransition, trans);
56 } 57 }
57 58
58 void AddVisitNode(const history::VisitRow& row, ListValue* list) { 59 void AddVisitNode(const history::VisitRow& row, ListValue* list) {
59 DictionaryValue* dict = new DictionaryValue(); 60 DictionaryValue* dict = new DictionaryValue();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (!temp_url.is_valid()) { 169 if (!temp_url.is_valid()) {
169 error_ = keys::kInvalidUrlError; 170 error_ = keys::kInvalidUrlError;
170 return false; 171 return false;
171 } 172 }
172 url->Swap(&temp_url); 173 url->Swap(&temp_url);
173 return true; 174 return true;
174 } 175 }
175 176
176 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { 177 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) {
177 double ms_from_epoch = 0.0; 178 double ms_from_epoch = 0.0;
178 if (!value->GetAsReal(&ms_from_epoch)) { 179 if (!value->GetAsDouble(&ms_from_epoch)) {
179 int ms_from_epoch_as_int = 0; 180 int ms_from_epoch_as_int = 0;
180 if (!value->GetAsInteger(&ms_from_epoch_as_int)) 181 if (!value->GetAsInteger(&ms_from_epoch_as_int))
181 return false; 182 return false;
182 ms_from_epoch = static_cast<double>(ms_from_epoch_as_int); 183 ms_from_epoch = static_cast<double>(ms_from_epoch_as_int);
183 } 184 }
184 // The history service has seconds resolution, while javascript Date() has 185 // The history service has seconds resolution, while javascript Date() has
185 // milliseconds resolution. 186 // milliseconds resolution.
186 double seconds_from_epoch = ms_from_epoch / 1000.0; 187 double seconds_from_epoch = ms_from_epoch / 1000.0;
187 // Time::FromDoubleT converts double time 0 to empty Time object. So we need 188 // Time::FromDoubleT converts double time 0 to empty Time object. So we need
188 // to do special handling here. 189 // to do special handling here.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 base::Time::Now(), // To the current time. 380 base::Time::Now(), // To the current time.
380 &cancelable_consumer_, 381 &cancelable_consumer_,
381 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete)); 382 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete));
382 383
383 return true; 384 return true;
384 } 385 }
385 386
386 void DeleteAllHistoryFunction::DeleteComplete() { 387 void DeleteAllHistoryFunction::DeleteComplete() {
387 SendAsyncResponse(); 388 SendAsyncResponse();
388 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698