summaryrefslogtreecommitdiffstats
path: root/content/browser/download/base_file_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fixed content::BaseFile::IsEmptyHash call to memset.joaodasilva@chromium.org2013-12-191-7/+11
| | | | | | | | | | | | The call to memset is meant to compare 32 bytes from the input string against a known string. The constant 32 was stored in kSha256HashLen, however the call to memset passed "sizeof(kSha256HashLen)" instead of simply "kSha256HashLen" as the string size. This meant that only the first 4 or 8 bytes of the string were being compared, instead of the expected 32. Credit to sl@conew.com for reporting on chromium-discuss. BUG=None Review URL: https://codereview.chromium.org/109793016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241975 0039d316-1c4b-4281-b951-d872f2087c98
* Move directory creation functions to base namespace.brettw@chromium.org2013-12-031-1/+1
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/100573002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238446 0039d316-1c4b-4281-b951-d872f2087c98
* Move temp file functions to base namespace.brettw@chromium.org2013-12-031-3/+2
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/99923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238427 0039d316-1c4b-4281-b951-d872f2087c98
* Move ReadFileToString to the base namespace.brettw@chromium.org2013-08-301-1/+1
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/19579005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220612 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of the message_loop header in content/, part 1.avi@chromium.org2013-07-181-1/+1
| | | | | | | | | | BUG=260807 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/19532003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212206 0039d316-1c4b-4281-b951-d872f2087c98
* Move PathExists to base namespace.brettw@chromium.org2013-07-111-16/+16
| | | | | | | | | BUG= TBR=jam@chromium.org Review URL: https://codereview.chromium.org/18286004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211147 0039d316-1c4b-4281-b951-d872f2087c98
* Move Copy* into the base namespace.brettw@chromium.org2013-07-091-1/+1
| | | | | | | | | | | This also creates a new base::internal namespace in file_util and I moved some of the internal functions in file_util to there. BUG= TBR=jam Review URL: https://codereview.chromium.org/18332014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210600 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of strings headers in content/browser/, part 1.avi@chromium.org2013-06-111-1/+1
| | | | | | | | | | BUG=247723 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/16755004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205449 0039d316-1c4b-4281-b951-d872f2087c98
* downloads: Improve download rate estimation.cbentzel@chromium.org2013-05-291-40/+0
| | | | | | | | | | | | | | | Previously, download rate was estimated as bytes_received/(current_time - download_start_time) Although simple, this would react slowly to dynamic changes in download time, or user initiated pauses. With this change, a ring buffer of the past 10 seconds of download time is used instead, and estimates are derived from that. It handles dynamic changes to bandwidth well. Pauses are handled reasonably well, as estimates are accurate after ten seconds - a better solution would be to clear the data rates when the user resumes from a pause. The main downside with this approach is it takes about 100 bytes of memory per active download, as well as adds some complexity. BUG=16390 TEST=content_unittests Review URL: https://chromiumcodereview.appspot.com/14697023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202874 0039d316-1c4b-4281-b951-d872f2087c98
* content: Use base::MessageLoop.xhwang@chromium.org2013-05-041-1/+1
| | | | | | | | | BUG=236029 R=avi@chromium.org Review URL: https://chromiumcodereview.appspot.com/14335017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198316 0039d316-1c4b-4281-b951-d872f2087c98
* Rewrite std::string("") to std::string(), Linux edition.dcheng@chromium.org2013-04-091-8/+8
| | | | | | | | | | | | | | | | | | | This patch was generated by running the empty_string clang tool across the Chromium Linux compilation database. Implicitly or explicitly constructing std::string() with a "" argument is inefficient as the caller needs to emit extra instructions to pass an argument, and the constructor needlessly copies a byte into internal storage. Rewriting these instances to simply call the default constructor appears to save ~14-18 kilobytes on an optimized release build. BUG=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020 Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Rewrite std::string("") to std::string(), Linux edition."dcheng@chromium.org2013-04-091-8/+8
| | | | | | | | | | | | | | This reverts commit e59558b78e8c6a1b0bd916a724724b638c3c91b6. Revert "Fix build after r193020." This reverts commit 558a35897f6b3ffbcaefde927c1f150b815d140a. Revert "Really fix build after r193020." This reverts commit e3748a79b523a8d365d4a33ef986eebb4186fa78. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193030 0039d316-1c4b-4281-b951-d872f2087c98
* Rewrite std::string("") to std::string(), Linux edition.dcheng@chromium.org2013-04-091-8/+8
| | | | | | | | | | | | | | | | | This patch was generated by running the empty_string clang tool across the Chromium Linux compilation database. Implicitly or explicitly constructing std::string() with a "" argument is inefficient as the caller needs to emit extra instructions to pass an argument, and the constructor needlessly copies a byte into internal storage. Rewriting these instances to simply call the default constructor appears to save ~14-18 kilobytes on an optimized release build. BUG=none Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
* Use base namespace for FilePath in content/browserbrettw@chromium.org2013-02-071-30/+30
| | | | | | Review URL: https://codereview.chromium.org/12213066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181349 0039d316-1c4b-4281-b951-d872f2087c98
* Initial CL for Downloads resumption.rdsmith@chromium.org2013-01-121-2/+7
| | | | | | | | | | | | | (Original work done by ahendrickson@chromium.org) BUG=7648 R=ahendrickson@chromium.org R=asanka@chromium.org Review URL: https://chromiumcodereview.appspot.com/11571025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176530 0039d316-1c4b-4281-b951-d872f2087c98
* Move scoped_temp_dir from base to base/filesbrettw@chromium.org2012-11-161-2/+2
| | | | | | | | | | Also add to base namespace. BUG= Review URL: https://codereview.chromium.org/11359217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168281 0039d316-1c4b-4281-b951-d872f2087c98
* Move download code to the content namespace.jam@chromium.org2012-10-261-28/+25
| | | | | | Review URL: https://codereview.chromium.org/11320016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164439 0039d316-1c4b-4281-b951-d872f2087c98
* Refactor BaseFile methods to return a DownloadInterruptReason instead of a ↵asanka@chromium.org2012-10-251-74/+92
| | | | | | | | | | | | net::Error. Also split the implementation into platform specific files. BUG=157245 Review URL: https://chromiumcodereview.appspot.com/11238044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163983 0039d316-1c4b-4281-b951-d872f2087c98
* Shift passage of FileStream in downloads system to be by scoped_ptr<>.rdsmith@chromium.org2012-10-171-40/+32
| | | | | | | | | | | | | | | | http://codereview.chromium.org/10912173/ constructs the DownloadFile, and thus the BaseFile, on the UI thread and then passes it to the FILE thread. DownloadFile / BaseFile may be constructed with a FileStream to which to write the download. The FileStream cannot be passed by linked_ptr<> in this case, as that is not thread safe. BUG=123998 R=benjhayden@chromium.org Review URL: https://chromiumcodereview.appspot.com/11028131 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162411 0039d316-1c4b-4281-b951-d872f2087c98
* Use the user's preferred downloads directory for creating the initial ↵asanka@chromium.org2012-09-151-25/+44
| | | | | | | | | | | download file. BUG=132240 Review URL: https://chromiumcodereview.appspot.com/10905284 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157022 0039d316-1c4b-4281-b951-d872f2087c98
* Add test for failing rename in BaseFileTest.asanka@chromium.org2012-07-121-0/+24
| | | | | | | | | | | | Also clean up temporary directory in BaseFileTest.ReadonlyBaseFile. BUG=none TEST=content_unittests Review URL: https://chromiumcodereview.appspot.com/10702130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146477 0039d316-1c4b-4281-b951-d872f2087c98
* net: Rename FileStream::Open/Close with OpenSync/CloseSync.satorux@chromium.org2012-02-091-1/+1
| | | | | | | | | | | | | | | | | | This is in preparation for implementing async versions of Open() and Close(). The existing clients are changed to use OpenSync/CloseSync. No logic is changed. The original patch was reverted as it broke linux_chromeos build. This patch includes fixes for the build. TEST=git try -r 121075 --bot=win,linux,mac,linux_chromeos,linux_chromeos_gtk,win_aura to confirm everything is built as before. BUG=72001 Review URL: https://chromiumcodereview.appspot.com/9373001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121202 0039d316-1c4b-4281-b951-d872f2087c98
* Back out r121064 from the trunk due to a compile failure.mark@chromium.org2012-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Builder%20%28dbg%29/builds/16/steps/compile/logs/stdio net: Rename FileStream::Open/Close with OpenSync/CloseSync. This is in preparation for implementing async versions of Open() and Close(). The existing clients are changed to use OpenSync/CloseSync. No logic is changed. TEST=try bots to confirm everythign is built as before. BUG=72001 Review URL: http://codereview.chromium.org/9349005 TBR=satorux@chromium.org Review URL: https://chromiumcodereview.appspot.com/9363036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121075 0039d316-1c4b-4281-b951-d872f2087c98
* net: Rename FileStream::Open/Close with OpenSync/CloseSync.satorux@chromium.org2012-02-081-1/+1
| | | | | | | | | | | | | | | | This is in preparation for implementing async versions of Open() and Close(). The existing clients are changed to use OpenSync/CloseSync. No logic is changed. TEST=try bots to confirm everythign is built as before. BUG=72001 Review URL: http://codereview.chromium.org/9349005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121064 0039d316-1c4b-4281-b951-d872f2087c98
* Added net logging to BaseFile.ahendrickson@chromium.org2012-02-051-11/+40
| | | | | | | | | | | | | | This enables net logging for BaseFile if any customer of BaseFile choose to take advantage of it -- none yet do. This is the second of 4 CLs that will enable net logging for downloads. BUG=None TEST=None Review URL: http://codereview.chromium.org/9223019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120510 0039d316-1c4b-4281-b951-d872f2087c98
* Added Net logging to FileStream.ahendrickson@chromium.org2012-02-021-2/+2
| | | | | | | | | | | | | The net logging doesn't currently do anything, but is ready if some system wants to pass it in. This is the first of 4 CLs that will enable net logging for downloads. BUG=None TEST=None Review URL: https://chromiumcodereview.appspot.com/9288084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120226 0039d316-1c4b-4281-b951-d872f2087c98
* In order to resume a download some more information needs to be gathered.ahendrickson@chromium.org2011-12-221-45/+168
| | | | | | | | | | | | | | | | | | This CL adds member data to classes to support this. It is the first of several CLs to implement download resumption. In addition hash information is propagated from DownloadFile to DownloadItem, because a new DownloadFile will be created when the download is resumed. It will also need to be persisted in order to resume across chrome runs. The plan is that data will be collected in DownloadResourceHandler::OnResponseStarted() and passed down to DownloadItem. On resume, it will pass the information from the resuming DownloadItem to ResourceDispatcherHost::BeginDownload(), which will set any required headers. BUG= 7648 TEST=None Review URL: http://codereview.chromium.org/8404049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115573 0039d316-1c4b-4281-b951-d872f2087c98
* Move download speed calculation to file thread / DownloadFile class.benwells@chromium.org2011-11-301-0/+53
| | | | | | | | | | | | | | This change doesn't change the way the calculation is performed but moves it to the file thread, in preperation for implementing a different speed calculation method. BUG=None TEST=Manually tested; automated tests needed. Review URL: http://codereview.chromium.org/8595004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112152 0039d316-1c4b-4281-b951-d872f2087c98
* Store the download file hash in the DownloadItem. This will be usefulnoelutz@google.com2011-11-101-1/+9
| | | | | | | | | | | | for the improved SafeBrowsing download protection later. BUG=102540 TEST=No visible change. Run DownloadItemTest, DownloadManagerTest Review URL: http://codereview.chromium.org/8511020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109471 0039d316-1c4b-4281-b951-d872f2087c98
* Move BrowserThread to content namespace.joi@chromium.org2011-11-021-0/+1
| | | | | | | | | TBR=owners BUG=98716 Review URL: http://codereview.chromium.org/8437002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108270 0039d316-1c4b-4281-b951-d872f2087c98
* Switch content tests to use BrowserThreadImpl directly.joi@chromium.org2011-10-311-2/+4
| | | | | | | | | BUG=98716 Review URL: http://codereview.chromium.org/8400060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107964 0039d316-1c4b-4281-b951-d872f2087c98
* Split BrowserThread into public API and private implementation, step 1.joi@chromium.org2011-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | Only content/ now has the ability to create BrowserThread objects, with the exception that tests can create the content::TestBrowserThread subclass, and (temporarily) code in chrome/ can create the DeprecatedBrowserThread subclass. A follow-up change will make content/ take care of its own thread creation, remove DeprecatedBrowserThread, and move all state and non-trivial constructors from BrowserThread down to BrowserThreadImpl. Also moved BrowserProcessSubThread into content/ namespace. As part of follow-up cleanup, chrome/ will stop using this class. BUG=98716 TEST=existing Review URL: http://codereview.chromium.org/8392042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107718 0039d316-1c4b-4281-b951-d872f2087c98
* Fix potential issue with BaseFile::AppendDataToFile().ahendrickson@chromium.org2011-09-231-5/+13
| | | | | | | | | | | | Split from CL 7134019. BUG=None TEST=None Review URL: http://codereview.chromium.org/7778005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102608 0039d316-1c4b-4281-b951-d872f2087c98
* Make BaseFile member functions return net::Error's.ahendrickson@chromium.org2011-09-041-40/+162
| | | | | | | | | | | | | | | | | | Moving towards giving the user feedback when a file system error occurs during a download. Split from CL 7134019. rdsmith: downloads phajdan.jr: downloads, base wtc: net brettw: base BUG=None TEST=None Review URL: http://codereview.chromium.org/7778003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99579 0039d316-1c4b-4281-b951-d872f2087c98
* Detect file system errors during downloads.ahendrickson@chromium.org2011-08-291-19/+62
| | | | | | | | | | | | | | Moving towards giving the user feedback when a file system error occurs during a download. Split from CL 7134019. BUG=85240 TEST=None Review URL: http://codereview.chromium.org/7646025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98725 0039d316-1c4b-4281-b951-d872f2087c98
* Move the save file code from chrome to content. This is just a file move so ↵jam@chromium.org2011-07-141-0/+230
the DEPS in content\browser\download is very permissive for now. The one exception is save_package.cc, where I had to split off the usage of SelectFileDialog because the code depended on grit which can't be used in content (circular dependencies in gyp). TBR=rdsmith BUG=82782 Review URL: http://codereview.chromium.org/7373004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92623 0039d316-1c4b-4281-b951-d872f2087c98