| OLD | NEW |
| 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 "content/browser/download/file_metadata_linux.h" | 5 #include "content/browser/download/file_metadata_linux.h" |
| 6 | 6 |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <sys/xattr.h> | 8 #include <sys/xattr.h> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 int flags) { | 22 int flags) { |
| 23 int result = setxattr(path, name, value, value_size, flags); | 23 int result = setxattr(path, name, value, value_size, flags); |
| 24 if (result) { | 24 if (result) { |
| 25 DPLOG(ERROR) | 25 DPLOG(ERROR) |
| 26 << "Could not set extended attribute " << name << " on file " << path; | 26 << "Could not set extended attribute " << name << " on file " << path; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 void AddOriginMetadataToFile(const base::FilePath& file, const GURL& source, | 30 void AddOriginMetadataToFile(const base::FilePath& file, const GURL& source, |
| 31 const GURL& referrer) { | 31 const GURL& referrer) { |
| 32 DCHECK(file_util::PathIsWritable(file)); | 32 DCHECK(base::PathIsWritable(file)); |
| 33 if (source.is_valid()) { | 33 if (source.is_valid()) { |
| 34 SetExtendedFileAttribute(file.value().c_str(), kSourceURLAttrName, | 34 SetExtendedFileAttribute(file.value().c_str(), kSourceURLAttrName, |
| 35 source.spec().c_str(), source.spec().length(), 0); | 35 source.spec().c_str(), source.spec().length(), 0); |
| 36 } | 36 } |
| 37 if (referrer.is_valid()) { | 37 if (referrer.is_valid()) { |
| 38 SetExtendedFileAttribute(file.value().c_str(), kReferrerURLAttrName, | 38 SetExtendedFileAttribute(file.value().c_str(), kReferrerURLAttrName, |
| 39 referrer.spec().c_str(), referrer.spec().length(), 0); | 39 referrer.spec().c_str(), referrer.spec().length(), 0); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace content | 43 } // namespace content |
| OLD | NEW |