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

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: Merged with trunk 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
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 net::NetLog* 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|.
93 // The |BoundNetLog| for this case is passed in via |info|, as it is
94 // constructed earlier in the download sequence.
Randy Smith (Not in Mondays) 2012/02/06 22:34:59 This comment seems misleading in context (neither
ahendrickson 2012/02/07 00:16:19 Done.
90 DownloadItemImpl(Delegate* delegate, 95 DownloadItemImpl(Delegate* delegate,
91 const DownloadCreateInfo& info, 96 const DownloadCreateInfo& info,
92 DownloadRequestHandleInterface* request_handle, 97 DownloadRequestHandleInterface* request_handle,
93 bool is_otr); 98 bool is_otr);
94 99
95 // Constructing for the "Save Page As..." feature: 100 // Constructing for the "Save Page As..." feature:
96 DownloadItemImpl(Delegate* delegate, 101 DownloadItemImpl(Delegate* delegate,
97 const FilePath& path, 102 const FilePath& path,
98 const GURL& url, 103 const GURL& url,
99 bool is_otr, 104 bool is_otr,
100 content::DownloadId download_id); 105 content::DownloadId download_id,
106 net::NetLog* net_log);
101 107
102 virtual ~DownloadItemImpl(); 108 virtual ~DownloadItemImpl();
103 109
104 // Overridden from DownloadItem. 110 // Overridden from DownloadItem.
105 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE; 111 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE;
106 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE; 112 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE;
107 virtual void UpdateObservers() OVERRIDE; 113 virtual void UpdateObservers() OVERRIDE;
108 virtual bool CanShowInFolder() OVERRIDE; 114 virtual bool CanShowInFolder() OVERRIDE;
109 virtual bool CanOpenDownload() OVERRIDE; 115 virtual bool CanOpenDownload() OVERRIDE;
110 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE; 116 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 virtual bool NeedsRename() const OVERRIDE; 203 virtual bool NeedsRename() const OVERRIDE;
198 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE; 204 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE;
199 virtual std::string DebugString(bool verbose) const OVERRIDE; 205 virtual std::string DebugString(bool verbose) const OVERRIDE;
200 virtual void MockDownloadOpenForTesting() OVERRIDE; 206 virtual void MockDownloadOpenForTesting() OVERRIDE;
201 virtual ExternalData* GetExternalData(const void* key) OVERRIDE; 207 virtual ExternalData* GetExternalData(const void* key) OVERRIDE;
202 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE; 208 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE;
203 209
204 private: 210 private:
205 // Construction common to all constructors. |active| should be true for new 211 // Construction common to all constructors. |active| should be true for new
206 // downloads and false for downloads from the history. 212 // downloads and false for downloads from the history.
207 void Init(bool active); 213 // |download_type| indicates to the net log system what kind of download
214 // this is.
215 void Init(bool active, download_net_logs::DownloadType download_type);
208 216
209 // Internal helper for maintaining consistent received and total sizes, and 217 // Internal helper for maintaining consistent received and total sizes, and
210 // hash state. 218 // hash state.
211 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state); 219 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state);
212 220
213 // Internal helper for maintaining consistent received and total sizes, and 221 // Internal helper for maintaining consistent received and total sizes, and
214 // setting the final hash. 222 // setting the final hash.
215 // Should only be called from |OnAllDataSaved|. 223 // Should only be called from |OnAllDataSaved|.
216 void ProgressComplete(int64 bytes_so_far, 224 void ProgressComplete(int64 bytes_so_far,
217 const std::string& final_hash); 225 const std::string& final_hash);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // only. 372 // only.
365 bool open_enabled_; 373 bool open_enabled_;
366 374
367 // Did the delegate delay calling Complete on this download? 375 // Did the delegate delay calling Complete on this download?
368 bool delegate_delayed_complete_; 376 bool delegate_delayed_complete_;
369 377
370 // External Data storage. All objects in the store 378 // External Data storage. All objects in the store
371 // are owned by the DownloadItemImpl. 379 // are owned by the DownloadItemImpl.
372 std::map<const void*, ExternalData*> external_data_map_; 380 std::map<const void*, ExternalData*> external_data_map_;
373 381
382 // Net log to use for this download.
383 const net::BoundNetLog bound_net_log_;
384
374 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 385 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
375 }; 386 };
376 387
377 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 388 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698