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

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 parent. 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* log);
mmenke 2012/02/03 17:59:45 nit: net_log. Below, too
Randy Smith (Not in Mondays) 2012/02/03 18:23:37 I'm somewhat uncomfortable with having different w
ahendrickson 2012/02/04 05:24:04 Done.
ahendrickson 2012/02/04 05:24:04 Two of the constructors now take BoundNetLogs, and
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);
94 97
95 // Constructing for the "Save Page As..." feature: 98 // Constructing for the "Save Page As..." feature:
96 DownloadItemImpl(Delegate* delegate, 99 DownloadItemImpl(Delegate* delegate,
97 const FilePath& path, 100 const FilePath& path,
98 const GURL& url, 101 const GURL& url,
99 bool is_otr, 102 bool is_otr,
100 content::DownloadId download_id); 103 content::DownloadId download_id,
104 net::NetLog* log);
101 105
102 virtual ~DownloadItemImpl(); 106 virtual ~DownloadItemImpl();
103 107
104 // Overridden from DownloadItem. 108 // Overridden from DownloadItem.
105 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE; 109 virtual void AddObserver(DownloadItem::Observer* observer) OVERRIDE;
106 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE; 110 virtual void RemoveObserver(DownloadItem::Observer* observer) OVERRIDE;
107 virtual void UpdateObservers() OVERRIDE; 111 virtual void UpdateObservers() OVERRIDE;
108 virtual bool CanShowInFolder() OVERRIDE; 112 virtual bool CanShowInFolder() OVERRIDE;
109 virtual bool CanOpenDownload() OVERRIDE; 113 virtual bool CanOpenDownload() OVERRIDE;
110 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE; 114 virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 virtual bool NeedsRename() const OVERRIDE; 201 virtual bool NeedsRename() const OVERRIDE;
198 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE; 202 virtual void OffThreadCancel(DownloadFileManager* file_manager) OVERRIDE;
199 virtual std::string DebugString(bool verbose) const OVERRIDE; 203 virtual std::string DebugString(bool verbose) const OVERRIDE;
200 virtual void MockDownloadOpenForTesting() OVERRIDE; 204 virtual void MockDownloadOpenForTesting() OVERRIDE;
201 virtual ExternalData* GetExternalData(const void* key) OVERRIDE; 205 virtual ExternalData* GetExternalData(const void* key) OVERRIDE;
202 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE; 206 virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE;
203 207
204 private: 208 private:
205 // Construction common to all constructors. |active| should be true for new 209 // Construction common to all constructors. |active| should be true for new
206 // downloads and false for downloads from the history. 210 // downloads and false for downloads from the history.
207 void Init(bool active); 211 // |download_type| indicates to the net log system what kind of download
212 // this is.
213 void Init(bool active, download_net_logs::DownloadType download_type);
208 214
209 // Internal helper for maintaining consistent received and total sizes, and 215 // Internal helper for maintaining consistent received and total sizes, and
210 // hash state. 216 // hash state.
211 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state); 217 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state);
212 218
213 // Internal helper for maintaining consistent received and total sizes, and 219 // Internal helper for maintaining consistent received and total sizes, and
214 // setting the final hash. 220 // setting the final hash.
215 // Should only be called from |OnAllDataSaved|. 221 // Should only be called from |OnAllDataSaved|.
216 void ProgressComplete(int64 bytes_so_far, 222 void ProgressComplete(int64 bytes_so_far,
217 const std::string& final_hash); 223 const std::string& final_hash);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // only. 370 // only.
365 bool open_enabled_; 371 bool open_enabled_;
366 372
367 // Did the delegate delay calling Complete on this download? 373 // Did the delegate delay calling Complete on this download?
368 bool delegate_delayed_complete_; 374 bool delegate_delayed_complete_;
369 375
370 // External Data storage. All objects in the store 376 // External Data storage. All objects in the store
371 // are owned by the DownloadItemImpl. 377 // are owned by the DownloadItemImpl.
372 std::map<const void*, ExternalData*> external_data_map_; 378 std::map<const void*, ExternalData*> external_data_map_;
373 379
380 // Net log to use for this download.
381 net::BoundNetLog bound_net_log_;
mmenke 2012/02/03 17:59:45 nit: const
ahendrickson 2012/02/04 05:24:04 Done.
382
374 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); 383 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl);
375 }; 384 };
376 385
377 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ 386 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698