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

Side by Side Diff: content/browser/download/base_file.cc

Issue 10784007: Place source URL of DownloadFile in extended attributes (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 4 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
OLDNEW
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/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/pickle.h" 11 #include "base/pickle.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "content/browser/download/download_net_log_parameters.h" 15 #include "content/browser/download/download_net_log_parameters.h"
16 #include "content/browser/download/download_stats.h" 16 #include "content/browser/download/download_stats.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
19 #include "crypto/secure_hash.h" 19 #include "crypto/secure_hash.h"
20 #include "net/base/file_stream.h" 20 #include "net/base/file_stream.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 22
23 #if defined(OS_WIN) 23 #if defined(OS_WIN)
24 #include <windows.h> 24 #include <windows.h>
25 #include <shellapi.h> 25 #include <shellapi.h>
26 26
27 #include "content/browser/safe_util_win.h" 27 #include "content/browser/safe_util_win.h"
28 #elif defined(OS_MACOSX) 28 #elif defined(OS_MACOSX)
29 #include "content/browser/file_metadata_mac.h" 29 #include "content/browser/file_metadata_mac.h"
30 #elif defined(OS_LINUX)
31 #include "content/browser/download/file_metadata_linux.h"
30 #endif 32 #endif
31 33
32 using content::BrowserThread; 34 using content::BrowserThread;
33 35
34 namespace { 36 namespace {
35 37
36 #define LOG_ERROR(o, e) \ 38 #define LOG_ERROR(o, e) \
37 LogError(__FILE__, __LINE__, __FUNCTION__, bound_net_log_, o, e) 39 LogError(__FILE__, __LINE__, __FUNCTION__, bound_net_log_, o, e)
38 40
39 // Logs the value and passes error on through, converting to a |net::Error|. 41 // Logs the value and passes error on through, converting to a |net::Error|.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 #if defined(OS_WIN) 465 #if defined(OS_WIN)
464 // Sets the Zone to tell Windows that this file comes from the internet. 466 // Sets the Zone to tell Windows that this file comes from the internet.
465 // We ignore the return value because a failure is not fatal. 467 // We ignore the return value because a failure is not fatal.
466 win_util::SetInternetZoneIdentifier(full_path_, 468 win_util::SetInternetZoneIdentifier(full_path_,
467 UTF8ToWide(source_url_.spec())); 469 UTF8ToWide(source_url_.spec()));
468 #elif defined(OS_MACOSX) 470 #elif defined(OS_MACOSX)
469 file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_, 471 file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_,
470 referrer_url_); 472 referrer_url_);
471 file_metadata::AddOriginMetadataToFile(full_path_, source_url_, 473 file_metadata::AddOriginMetadataToFile(full_path_, source_url_,
472 referrer_url_); 474 referrer_url_);
475 #elif defined(OS_LINUX)
476 content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
473 #endif 477 #endif
474 } 478 }
475 479
476 void BaseFile::CreateFileStream() { 480 void BaseFile::CreateFileStream() {
477 file_stream_.reset(new net::FileStream(bound_net_log_.net_log())); 481 file_stream_.reset(new net::FileStream(bound_net_log_.net_log()));
478 file_stream_->SetBoundNetLogSource(bound_net_log_); 482 file_stream_->SetBoundNetLogSource(bound_net_log_);
479 } 483 }
480 484
481 net::Error BaseFile::Open() { 485 net::Error BaseFile::Open() {
482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 486 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { 552 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
549 base::TimeDelta diff = current_time - start_tick_; 553 base::TimeDelta diff = current_time - start_tick_;
550 int64 diff_ms = diff.InMilliseconds(); 554 int64 diff_ms = diff.InMilliseconds();
551 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 555 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
552 } 556 }
553 557
554 int64 BaseFile::CurrentSpeed() const { 558 int64 BaseFile::CurrentSpeed() const {
555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
556 return CurrentSpeedAtTime(base::TimeTicks::Now()); 560 return CurrentSpeedAtTime(base::TimeTicks::Now());
557 } 561 }
562
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/file_metadata_linux.h » ('j') | content/browser/download/file_metadata_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698