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

Side by Side Diff: chrome/browser/importer/safari_importer.mm

Issue 6594096: Clean up CF To NS Casts and make them slightly safer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix space Created 9 years, 9 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 | « chrome/browser/cocoa/keystone_glue.mm ('k') | chrome/browser/ui/cocoa/file_metadata.mm » ('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) 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 <Cocoa/Cocoa.h> 5 #include <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/importer/safari_importer.h" 7 #include "chrome/browser/importer/safari_importer.h"
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/mac/mac_util.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/scoped_nsobject.h" 15 #include "base/scoped_nsobject.h"
15 #include "base/string16.h" 16 #include "base/string16.h"
16 #include "base/sys_string_conversions.h" 17 #include "base/sys_string_conversions.h"
17 #include "base/time.h" 18 #include "base/time.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "chrome/browser/history/history_types.h" 20 #include "chrome/browser/history/history_types.h"
20 #include "chrome/browser/importer/importer_bridge.h" 21 #include "chrome/browser/importer/importer_bridge.h"
21 #include "chrome/browser/importer/importer_data_types.h" 22 #include "chrome/browser/importer/importer_data_types.h"
22 #include "chrome/common/sqlite_utils.h" 23 #include "chrome/common/sqlite_utils.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (!rows.empty() && !cancelled()) { 320 if (!rows.empty() && !cancelled()) {
320 bridge_->SetHistoryItems(rows, history::SOURCE_SAFARI_IMPORTED); 321 bridge_->SetHistoryItems(rows, history::SOURCE_SAFARI_IMPORTED);
321 } 322 }
322 } 323 }
323 324
324 double SafariImporter::HistoryTimeToEpochTime(NSString* history_time) { 325 double SafariImporter::HistoryTimeToEpochTime(NSString* history_time) {
325 DCHECK(history_time); 326 DCHECK(history_time);
326 // Add Difference between Unix epoch and CFAbsoluteTime epoch in seconds. 327 // Add Difference between Unix epoch and CFAbsoluteTime epoch in seconds.
327 // Unix epoch is 1970-01-01 00:00:00.0 UTC, 328 // Unix epoch is 1970-01-01 00:00:00.0 UTC,
328 // CF epoch is 2001-01-01 00:00:00.0 UTC. 329 // CF epoch is 2001-01-01 00:00:00.0 UTC.
329 return CFStringGetDoubleValue(reinterpret_cast<CFStringRef>(history_time)) + 330 return CFStringGetDoubleValue(base::mac::NSToCFCast(history_time)) +
330 kCFAbsoluteTimeIntervalSince1970; 331 kCFAbsoluteTimeIntervalSince1970;
331 } 332 }
332 333
333 void SafariImporter::ParseHistoryItems( 334 void SafariImporter::ParseHistoryItems(
334 std::vector<history::URLRow>* history_items) { 335 std::vector<history::URLRow>* history_items) {
335 DCHECK(history_items); 336 DCHECK(history_items);
336 337
337 // Construct ~/Library/Safari/History.plist path 338 // Construct ~/Library/Safari/History.plist path
338 NSString* library_dir = [NSString 339 NSString* library_dir = [NSString
339 stringWithUTF8String:library_dir_.value().c_str()]; 340 stringWithUTF8String:library_dir_.value().c_str()];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (!last_visit_str) 388 if (!last_visit_str)
388 continue; 389 continue;
389 390
390 // Convert Safari's last visit time to Unix Epoch time. 391 // Convert Safari's last visit time to Unix Epoch time.
391 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 392 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
392 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); 393 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch));
393 394
394 history_items->push_back(row); 395 history_items->push_back(row);
395 } 396 }
396 } 397 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/keystone_glue.mm ('k') | chrome/browser/ui/cocoa/file_metadata.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698