|
|
Created:
8 years, 5 months ago by cristian.patrasciuc Modified:
8 years, 3 months ago CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam, rdsmith+dwatch_chromium.org Base URL:
http://src.chromium.org/svn/trunk/src/ Visibility:
Public. |
DescriptionAdded functionality such that on Linux, after downloading a file,
the source URL and referrer URL are stored as extended file attributes.
Also see http://www.freedesktop.org/wiki/CommonExtendedAttributes
BUG=45903
TEST=content_unittests/file_metadata_unittest_linux.cc/FileMetadataLinuxTest
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=148729
Patch Set 1 : #Patch Set 2 : #Patch Set 3 : #Patch Set 4 : #
Total comments: 2
Patch Set 5 : #
Total comments: 4
Patch Set 6 : #Patch Set 7 : #
Total comments: 1
Patch Set 8 : #
Total comments: 4
Messages
Total messages: 31 (0 generated)
Preliminary review request. Besides possible code issues or style problems, some things that I'm not sure I used correctly: - The xattr.h header file. On my machine is in <sys/xattr.h>, on the man page it says <attr/xattr.h> - The macro that I used in base_file.cc to include my code might be too broad. I could not test it this works or affects Android, ChromeOS, etc. - The second unittest might not be needed. That scenario should not happen in Chrome since we always set the attribute on a newly created/downloaded file. Also, if you are not the correct reviewer please point me to the right one. Thanks.
Ben, as downloads linux expert (:-}), would you be willing to take a look at this CL?
On 2012/07/15 21:29:21, cristian.patrasciuc wrote: > Preliminary review request. > > Besides possible code issues or style problems, some things that I'm not sure I > used correctly: > - The xattr.h header file. On my machine is in <sys/xattr.h>, on the man page it > says <attr/xattr.h> > - The macro that I used in base_file.cc to include my code might be too broad. I > could not test it this works or affects Android, ChromeOS, etc. I see /usr/include/sys/xattr.h on my linux box. I do not see attr/xattr.h. I'm happy to rely on the trybots' verdict. > - The second unittest might not be needed. That scenario should not happen in > Chrome since we always set the attribute on a newly created/downloaded file. Since it's a unit test and not a browser test, it should be fast enough that the extra coverage is worth the fraction of a second. Also, this is a lower-level library than chrome downloads, so it should not rely on behaviors of the downloads system, especially behaviors that may change when downloads resumption is done. > > Also, if you are not the correct reviewer please point me to the right one. > Thanks. Looks good pending trybots.
On 2012/07/16 15:26:38, benjhayden_chromium wrote: > On 2012/07/15 21:29:21, cristian.patrasciuc wrote: > > Preliminary review request. > > > > Besides possible code issues or style problems, some things that I'm not sure > I > > used correctly: > > - The xattr.h header file. On my machine is in <sys/xattr.h>, on the man page > it > > says <attr/xattr.h> > > - The macro that I used in base_file.cc to include my code might be too broad. > I > > could not test it this works or affects Android, ChromeOS, etc. > > I see /usr/include/sys/xattr.h on my linux box. I do not see attr/xattr.h. > > I'm happy to rely on the trybots' verdict. > > > - The second unittest might not be needed. That scenario should not happen in > > Chrome since we always set the attribute on a newly created/downloaded file. > > Since it's a unit test and not a browser test, it should be fast enough that the > extra coverage is worth the fraction of a second. Also, this is a lower-level > library than chrome downloads, so it should not rely on behaviors of the > downloads system, especially behaviors that may change when downloads resumption > is done. > > > > > Also, if you are not the correct reviewer please point me to the right one. > > Thanks. > > Looks good pending trybots. I thought I could run the trybots for your cl directly, but it didn't work, so I patched your CL into a fresh client and ran the bots from there: https://chromiumcodereview.appspot.com/10790013 Looks like linux_rel and linux_chromeos have sys/xattr.h, but caught a compile-time error. http://build.chromium.org/p/tryserver.chromium/builders/linux_rel/builds/3958... Please also remove the blank lines at the ends of the files.
Please see https://chromiumcodereview.appspot.com/10790013 patch set 3 for one way to avoid the compile error. I'm not sure if it's the best way. With that fixed, it looks like DCHECK(referrer.valid()) fails on linux_rel for most downloads tests. http://build.chromium.org/p/tryserver.chromium/builders/linux_rel/builds/3960... You can probably fix this with if (referrer.valid()) SetExtendedFileAttribute(...);
Looks like this will also fail on ext file systems unless they're mounted with -o user_xattr. http://archlinux.2023198.n4.nabble.com/Cannot-set-xattr-td2038548.html This happens on my work station, so it is likely to happen on other engineers' work stations as well. Perhaps the test should either mount a disk image or disable itself if the filesystem does not support user_xattr?
Is there a standard way to disable a test programatically? Regarding the new lines at the end of the files, I added them because the Lint column here on the code review site told me to do so. I will upload a new patch set tomorrow once I'll figure out how to disable the test automatically if extended attributes are not supported. Thanks.
On 2012/07/17 18:04:50, cristian.patrasciuc wrote: > Is there a standard way to disable a test programatically? > > Regarding the new lines at the end of the files, I added them because the Lint > column here on the code review site told me to do so. That's interesting. I've always ignored that column because it's always shown either 0 errors or ? errors. I don't see anything in the style guide about blank lines at ends of files, so I suppose you can keep them if you want. > > I will upload a new patch set tomorrow once I'll figure out how to disable the > test automatically if extended attributes are not supported. > > Thanks. Usually we disable tests on whole platforms using #if defined(OS_FOO), but since we want to be more specific and dynamic here, I think you can just do this: TEST_F(FileMetadataLinuxTest, CheckMetadataSetCorrectly) { if (IsXAttrDisabled()) { LOG(WARNING) << "Not testing file_metadata::AddOriginMetadataToFile() because xattrs are not supported on this filesystem"; return; } ... }
On 2012/07/17 18:49:51, benjhayden_chromium wrote: > On 2012/07/17 18:04:50, cristian.patrasciuc wrote: > > Is there a standard way to disable a test programatically? > > > > Regarding the new lines at the end of the files, I added them because the Lint > > column here on the code review site told me to do so. > > That's interesting. I've always ignored that column because it's always shown > either 0 errors or ? errors. > I don't see anything in the style guide about blank lines at ends of files, so I > suppose you can keep them if you want. The style guide says to minimize vertical whitespace: "This is more a principle than a rule: don't use blank lines when you don't have to. In particular, don't put more than one or two blank lines between functions, resist starting functions with a blank line, don't end functions with a blank line, and be discriminating with your use of blank lines inside functions. The basic principle is: The more code that fits on one screen, the easier it is to follow and understand the control flow of the program. Of course, readability can suffer from code being too dense as well as too spread out, so use your judgement. But in general, minimize use of vertical whitespace." > > > > > I will upload a new patch set tomorrow once I'll figure out how to disable the > > test automatically if extended attributes are not supported. > > > > Thanks. > > Usually we disable tests on whole platforms using #if defined(OS_FOO), but since > we want to be more specific and dynamic here, I think you can just do this: > TEST_F(FileMetadataLinuxTest, CheckMetadataSetCorrectly) { > if (IsXAttrDisabled()) { > LOG(WARNING) << "Not testing file_metadata::AddOriginMetadataToFile() > because xattrs are not supported on this filesystem"; > return; > } > ... > }
I uploaded a new patch that should fix the above mentioned issues.
On 2012/07/19 17:20:16, cristian.patrasciuc wrote: > I uploaded a new patch that should fix the above mentioned issues. Fails on the linux_rel bot: http://build.chromium.org/p/tryserver.chromium/builders/linux_rel/builds/4059... http://codereview.chromium.org/10790013/
I didn't read carefully the man page of setxattr in case of disabled extended attributes. It's the 'errno' variable that is set to ENOTSUP, not the return value of the setxattr call. I think that file systems on which the tests are run don't support xattr. The last patch should fix this.
I also have to specify a namespace for the test attribute, otherwise it will always fail.
A couple nits. The trybots are almost done and looking good so far. http://codereview.chromium.org/10790013/ http://codereview.chromium.org/10784007/diff/25007/content/browser/file_metad... File content/browser/file_metadata_unittest_linux.cc (right): http://codereview.chromium.org/10784007/diff/25007/content/browser/file_metad... content/browser/file_metadata_unittest_linux.cc:88: ScopedTempDir temp_dir_; Please keep member variables private and expose them with accessors as necessary. http://codereview.chromium.org/10784007/diff/25007/content/browser/file_metad... content/browser/file_metadata_unittest_linux.cc:97: LOG(INFO) << "Test is skipped because extended attributes are not " Please put this message just once in SetUp instead of in each TEST_F.
I added a new patch with the changes you requested.
lgtm
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cristian.patrasciuc@gmail.com/10784007...
Presubmit check for 10784007-18003 failed and returned exit status 1. Running presubmit commit checks ... ** Presubmit ERRORS ** Missing LGTM from an OWNER for files in these directories: content content/browser Presubmit checks took 1.1s to calculate.
Darin, can we have a rubberstamp? On 2012/07/23 17:04:58, I haz the power (commit-bot) wrote: > Presubmit check for 10784007-18003 failed and returned exit status 1. > > Running presubmit commit checks ... > > ** Presubmit ERRORS ** > Missing LGTM from an OWNER for files in these directories: > content > content/browser > > Presubmit checks took 1.1s to calculate.
https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... File content/browser/file_metadata_linux.h (right): https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... content/browser/file_metadata_linux.h:13: namespace file_metadata { nit: why is this in content/browser/ and not content/browser/download/? nit: why the namespace? namespaces are supposed to match directory names (note: we have a lot of violations of this rule in the source tree). https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... content/browser/file_metadata_linux.h:19: const char kSourceURLAttrName[] = "user.xdg.origin.url"; nit: just declare these here, define them in the .cc file, and export them instead? that way you don't end up duplicating these into each translation unit. sure, the linker will probably eliminate duplicate symbols, but why add more work for the linker? :-)
https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... File content/browser/file_metadata_linux.h (right): https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... content/browser/file_metadata_linux.h:13: namespace file_metadata { There is already an implementation for Mac OS, under content/browser/file_metadata_mac.h/mm. I decided to put the linux implementation in the same folder and to use the same namespace (i.e. file_metadata). If it's required I can move them (both linux and mac implementations) under content/browser/download in a separate CL. They are only used in content/browser/download/base_file.cc so there should be no problem. https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/fi... content/browser/file_metadata_linux.h:19: const char kSourceURLAttrName[] = "user.xdg.origin.url"; On 2012/07/24 05:00:04, darin wrote: > nit: just declare these here, define them in the .cc file, and export them > instead? that way you don't end up duplicating these into each translation > unit. sure, the linker will probably eliminate duplicate symbols, but why add > more work for the linker? :-) Done.
On Tue, Jul 24, 2012 at 4:20 AM, <cristian.patrasciuc@gmail.com> wrote: > > https://chromiumcodereview.**appspot.com/10784007/diff/** > 18003/content/browser/file_**metadata_linux.h<https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/file_metadata_linux.h> > File content/browser/file_metadata_**linux.h (right): > > https://chromiumcodereview.**appspot.com/10784007/diff/** > 18003/content/browser/file_**metadata_linux.h#newcode13<https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/file_metadata_linux.h#newcode13> > content/browser/file_metadata_**linux.h:13: namespace file_metadata { > There is already an implementation for Mac OS, under > content/browser/file_metadata_**mac.h/mm. I decided to put the linux > implementation in the same folder and to use the same namespace (i.e. > file_metadata). If it's required I can move them (both linux and mac > implementations) under content/browser/download in a separate CL. They > are only used in content/browser/download/base_**file.cc so there should > be no problem. > > Yes, I think they should be moved. You can move the Mac version as a separate CL if you prefer. > > https://chromiumcodereview.**appspot.com/10784007/diff/** > 18003/content/browser/file_**metadata_linux.h#newcode19<https://chromiumcodereview.appspot.com/10784007/diff/18003/content/browser/file_metadata_linux.h#newcode19> > content/browser/file_metadata_**linux.h:19: const char > kSourceURLAttrName[] = "user.xdg.origin.url"; > On 2012/07/24 05:00:04, darin wrote: > >> nit: just declare these here, define them in the .cc file, and export >> > them > >> instead? that way you don't end up duplicating these into each >> > translation > >> unit. sure, the linker will probably eliminate duplicate symbols, but >> > why add > >> more work for the linker? :-) >> > > Done. > > https://chromiumcodereview.**appspot.com/10784007/<https://chromiumcodereview... >
I moved the files to content/browser/download. For the MAC-related ones I'll create a separate CL after this one will be committed.
https://chromiumcodereview.appspot.com/10784007/diff/28001/content/browser/do... File content/browser/download/file_metadata_linux.h (right): https://chromiumcodereview.appspot.com/10784007/diff/28001/content/browser/do... content/browser/download/file_metadata_linux.h:13: namespace file_metadata { nit: this shouldn't be in its own namespace: From the style guide: "With named namespaces, choose the name based on the project, and possibly its path." http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namesp...
Since there is no content::download namespace yet and the classes from content/download are either in no namespace or in the "content" namespace, I chose to put my function in the "content" namespace.
LGTM https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... File content/browser/download/file_metadata_unittest_linux.cc (right): https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... content/browser/download/file_metadata_unittest_linux.cc:22: namespace { you can also put the test in the content namespace so you don't need to write content:: in front of content bits. namespace content { namespace { ... } // namespace } // namespace content
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cristian.patrasciuc@gmail.com/10784007...
Try job failure for 10784007-29007 (retry) on linux_clang for step "compile" (clobber build). It's a second try, previously, step "compile" failed. http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_clan...
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cristian.patrasciuc@gmail.com/10784007...
Change committed as 148729
https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... File content/browser/download/file_metadata_linux.cc (right): https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... content/browser/download/file_metadata_linux.cc:25: DPLOG(ERROR) How about returning bool success value, and letting the caller handle it? https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... content/browser/download/file_metadata_linux.cc:32: DCHECK(file_util::PathIsWritable(file)); Same here. You should return bool, and return false when path is not writable. Same with "silent" error handling below. The rationale is that now this became a part of the API, and once this has more callers, the problem becomes harder to repair. https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... File content/browser/download/file_metadata_unittest_linux.cc (right): https://chromiumcodereview.appspot.com/10784007/diff/29007/content/browser/do... content/browser/download/file_metadata_unittest_linux.cc:117: if (!is_xattr_supported()) return; nit: Each statement should be on its own line. Please move the return to new line, same below. |