Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / child / file_info_util.cc
blob40a11fbce5ac191d2bddf6158be2ed3e0adf3d60
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/file_info_util.h"
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebFileInfo.h"
10 namespace content {
12 void FileInfoToWebFileInfo(const base::File::Info& file_info,
13 blink::WebFileInfo* web_file_info) {
14 DCHECK(web_file_info);
15 // Blink now expects NaN as uninitialized/null Date.
16 if (file_info.last_modified.is_null())
17 web_file_info->modificationTime = std::numeric_limits<double>::quiet_NaN();
18 else
19 web_file_info->modificationTime = file_info.last_modified.ToJsTime();
20 web_file_info->length = file_info.size;
21 if (file_info.is_directory)
22 web_file_info->type = blink::WebFileInfo::TypeDirectory;
23 else
24 web_file_info->type = blink::WebFileInfo::TypeFile;
27 static_assert(std::numeric_limits<double>::has_quiet_NaN,
28 "should have quiet NaN");
30 } // namespace content