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

Side by Side Diff: content/browser/download/download_item_impl.h

Issue 9121053: Added net logging to DownloadItem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use BoundNetLog arguments in DownloadItemImpl constructors. Created 8 years, 10 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) 2011 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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "content/browser/download/download_net_log_parameters.h"
17 #include "content/browser/download/download_request_handle.h" 18 #include "content/browser/download/download_request_handle.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "content/public/browser/download_id.h" 20 #include "content/public/browser/download_id.h"
20 #include "content/public/browser/download_item.h" 21 #include "content/public/browser/download_item.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/base/net_log.h"
23 25
24 26
25 // See download_item.h for usage. 27 // See download_item.h for usage.
26 class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { 28 class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
27 public: 29 public:
28 // Delegate is defined in DownloadItemImpl (rather than DownloadItem) 30 // Delegate is defined in DownloadItemImpl (rather than DownloadItem)
29 // as it's relevant to the class implementation (class methods need to 31 // as it's relevant to the class implementation (class methods need to
30 // call into it) and doesn't have anything to do with its interface. 32 // call into it) and doesn't have anything to do with its interface.
31 // Despite this, the delegate methods take DownloadItems as arguments 33 // Despite this, the delegate methods take DownloadItems as arguments
32 // (rather than DownloadItemImpls) so that classes that inherit from it 34 // (rather than DownloadItemImpls) so that classes that inherit from it
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 75
74 private: 76 private:
75 // For "Outlives attached DownloadItemImpl" invariant assertion. 77 // For "Outlives attached DownloadItemImpl" invariant assertion.
76 int count_; 78 int count_;
77 }; 79 };
78 80
79 // Note that it is the responsibility of the caller to ensure that a 81 // Note that it is the responsibility of the caller to ensure that a
80 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor 82 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor
81 // outlives the DownloadItemImpl. 83 // outlives the DownloadItemImpl.
82 84
83 // Constructing from persistent store: 85 // Constructing from persistent store:
Randy Smith (Not in Mondays) 2012/02/07 22:56:08 All the back and forth we've had on this issue mak
ahendrickson 2012/02/07 23:04:22 Done.
84 DownloadItemImpl(Delegate* delegate, 86 DownloadItemImpl(Delegate* delegate,
85 content::DownloadId download_id, 87 content::DownloadId download_id,
86 const DownloadPersistentStoreInfo& info); 88 const DownloadPersistentStoreInfo& info,
89 const net::BoundNetLog& bound_net_log);
87 90
88 // Constructing for a regular download. 91 // Constructing for a regular download.
89 // Takes ownership of the object pointed to by |request_handle|. 92 // Takes ownership of the object pointed to by |request_handle|.
90 DownloadItemImpl(Delegate* delegate, 93 DownloadItemImpl(Delegate* delegate,
91 const DownloadCreateInfo& info, 94 const DownloadCreateInfo& info,
92 DownloadRequestHandleInterface* request_handle, 95 DownloadRequestHandleInterface* request_handle,
93 bool is_otr); 96 bool is_otr,
97 const net::BoundNetLog& bound_net_log);
94 98
95 // Constructing for the "Save Page As..." feature: 99 // Constructing for the "Save Page As..." feature:
96 DownloadItemImpl(Delegate* delegate, 100 DownloadItemImpl(Delegate* delegate,
97 const FilePath& path, 101 const FilePath& path,
98 const GURL& url, 102 const GURL& url,
99 bool is_otr, 103 bool is_otr,
100 content::DownloadId download_id); 104 content::DownloadId download_id,
105 const net::BoundNetLog& bound_net_log);
101 106
102 virtual ~DownloadItemImpl(); 107 virtual ~DownloadItemImpl();
103 108
104 // Overridden from DownloadItem. 109 // Overridden from DownloadItem.
105 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE; 110 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE;
106 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE; 111 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE;
107 virtual void UpdateObservers() OVERRIDE; 112 virtual void UpdateObservers() OVERRIDE;
108 virtual bool CanShowInFolder() OVERRIDE; 113 virtual bool CanShowInFolder() OVERRIDE;
109 virtual bool CanOpenDownload() OVERRIDE; 114 virtual bool CanOpenDownload() OVERRIDE;
110 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE; 115 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 virtual bool NeedsRename() const OVERRIDE; 202 virtual bool NeedsRename() const OVERRIDE;
198 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE; 203 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE;
199 virtual std::string DebugString(bool verbose) const OVERRIDE; 204 virtual std::string DebugString(bool verbose) const OVERRIDE;
200 virtual void MockDownloadOpenForTesting() OVERRIDE; 205 virtual void MockDownloadOpenForTesting() OVERRIDE;
201 virtual ExternalData* GetExternalData(const void* key) OVERRIDE; 206 virtual ExternalData* GetExternalData(const void* key) OVERRIDE;
202 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE; 207 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE;
203 208
204 private: 209 private:
205 // Construction common to all constructors. |active| should be true for new 210 // Construction common to all constructors. |active| should be true for new
206 // downloads and false for downloads from the history. 211 // downloads and false for downloads from the history.
207 void Init(bool active); 212 // |download_type| indicates to the net log system what kind of download
213 // this is.
214 void Init(bool active, download_net_logs::DownloadType download_type);
208 215
209 // Internal helper for maintaining consistent received and total sizes, and 216 // Internal helper for maintaining consistent received and total sizes, and
210 // hash state. 217 // hash state.
211 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state); 218 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state);
212 219
213 // Internal helper for maintaining consistent received and total sizes, and 220 // Internal helper for maintaining consistent received and total sizes, and
214 // setting the final hash. 221 // setting the final hash.
215 // Should only be called from |OnAllDataSaved|. 222 // Should only be called from |OnAllDataSaved|.
216 void ProgressComplete(int64 bytes_so_far, 223 void ProgressComplete(int64 bytes_so_far,
217 const std::string& final_hash); 224 const std::string& final_hash);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // only. 371 // only.
365 bool open_enabled_; 372 bool open_enabled_;
366 373
367 // Did the delegate delay calling Complete on this download? 374 // Did the delegate delay calling Complete on this download?
368 bool delegate_delayed_complete_; 375 bool delegate_delayed_complete_;
369 376
370 // External Data storage. All objects in the store 377 // External Data storage. All objects in the store
371 // are owned by the DownloadItemImpl. 378 // are owned by the DownloadItemImpl.
372 std::map<const void*, ExternalData*> external_data_map_; 379 std::map<const void*, ExternalData*> external_data_map_;
373 380
381 // Net log to use for this download.
382 const net::BoundNetLog bound_net_log_;
383
374 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 384 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
375 }; 385 };
376 386
377 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 387 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698