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

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

Issue 10821069: Moving file_metadata files under content/browser/download (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Git-based patch to overcome the 'svn mv' problem 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
« no previous file with comments | « no previous file | content/browser/download/file_metadata_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/download/file_metadata_mac.h"
30 #elif defined(OS_LINUX) 30 #elif defined(OS_LINUX)
31 #include "content/browser/download/file_metadata_linux.h" 31 #include "content/browser/download/file_metadata_linux.h"
32 #endif 32 #endif
33 33
34 using content::BrowserThread; 34 using content::BrowserThread;
35 35
36 namespace { 36 namespace {
37 37
38 #define LOG_ERROR(o, e) \ 38 #define LOG_ERROR(o, e) \
39 LogError(__FILE__, __LINE__, __FUNCTION__, bound_net_log_, o, e) 39 LogError(__FILE__, __LINE__, __FUNCTION__, bound_net_log_, o, e)
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 void BaseFile::AnnotateWithSourceInformation() { 461 void BaseFile::AnnotateWithSourceInformation() {
462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
463 DCHECK(!detached_); 463 DCHECK(!detached_);
464 464
465 #if defined(OS_WIN) 465 #if defined(OS_WIN)
466 // 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.
467 // We ignore the return value because a failure is not fatal. 467 // We ignore the return value because a failure is not fatal.
468 win_util::SetInternetZoneIdentifier(full_path_, 468 win_util::SetInternetZoneIdentifier(full_path_,
469 UTF8ToWide(source_url_.spec())); 469 UTF8ToWide(source_url_.spec()));
470 #elif defined(OS_MACOSX) 470 #elif defined(OS_MACOSX)
471 file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_, 471 content::AddQuarantineMetadataToFile(full_path_, source_url_, referrer_url_);
472 referrer_url_); 472 content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
473 file_metadata::AddOriginMetadataToFile(full_path_, source_url_,
474 referrer_url_);
475 #elif defined(OS_LINUX) 473 #elif defined(OS_LINUX)
476 content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_); 474 content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
477 #endif 475 #endif
478 } 476 }
479 477
480 void BaseFile::CreateFileStream() { 478 void BaseFile::CreateFileStream() {
481 file_stream_.reset(new net::FileStream(bound_net_log_.net_log())); 479 file_stream_.reset(new net::FileStream(bound_net_log_.net_log()));
482 file_stream_->SetBoundNetLogSource(bound_net_log_); 480 file_stream_->SetBoundNetLogSource(bound_net_log_);
483 } 481 }
484 482
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 base::TimeDelta diff = current_time - start_tick_; 551 base::TimeDelta diff = current_time - start_tick_;
554 int64 diff_ms = diff.InMilliseconds(); 552 int64 diff_ms = diff.InMilliseconds();
555 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 553 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
556 } 554 }
557 555
558 int64 BaseFile::CurrentSpeed() const { 556 int64 BaseFile::CurrentSpeed() const {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 557 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
560 return CurrentSpeedAtTime(base::TimeTicks::Now()); 558 return CurrentSpeedAtTime(base::TimeTicks::Now());
561 } 559 }
562 560
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/file_metadata_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698