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

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

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "content/browser/loader/resource_handler.h" 11 #include "content/browser/loader/resource_handler.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace net { 14 namespace net {
15 class URLRequest; 15 class URLRequest;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 class SaveFileManager; 19 class SaveFileManager;
20 20
21 // Forwards data to the save thread. 21 // Forwards data to the save thread.
22 class SaveFileResourceHandler : public ResourceHandler { 22 class SaveFileResourceHandler : public ResourceHandler {
23 public: 23 public:
24 SaveFileResourceHandler(net::URLRequest* request, 24 SaveFileResourceHandler(net::URLRequest* request,
25 int render_process_host_id, 25 int render_process_host_id,
26 int render_view_id, 26 int render_view_id,
27 const GURL& url, 27 const GURL& url,
28 SaveFileManager* manager); 28 SaveFileManager* manager);
29 virtual ~SaveFileResourceHandler(); 29 ~SaveFileResourceHandler() override;
30 30
31 // ResourceHandler Implementation: 31 // ResourceHandler Implementation:
32 virtual bool OnUploadProgress(uint64 position, uint64 size) override; 32 bool OnUploadProgress(uint64 position, uint64 size) override;
33 33
34 // Saves the redirected URL to final_url_, we need to use the original 34 // Saves the redirected URL to final_url_, we need to use the original
35 // URL to match original request. 35 // URL to match original request.
36 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 36 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
37 ResourceResponse* response, 37 ResourceResponse* response,
38 bool* defer) override; 38 bool* defer) override;
39 39
40 // Sends the download creation information to the download thread. 40 // Sends the download creation information to the download thread.
41 virtual bool OnResponseStarted(ResourceResponse* response, 41 bool OnResponseStarted(ResourceResponse* response, bool* defer) override;
42 bool* defer) override;
43 42
44 // Pass-through implementation. 43 // Pass-through implementation.
45 virtual bool OnWillStart(const GURL& url, bool* defer) override; 44 bool OnWillStart(const GURL& url, bool* defer) override;
46 45
47 // Pass-through implementation. 46 // Pass-through implementation.
48 virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; 47 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override;
49 48
50 // Creates a new buffer, which will be handed to the download thread for file 49 // Creates a new buffer, which will be handed to the download thread for file
51 // writing and deletion. 50 // writing and deletion.
52 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 51 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
53 int* buf_size, 52 int* buf_size,
54 int min_size) override; 53 int min_size) override;
55 54
56 // Passes the buffer to the download file writer. 55 // Passes the buffer to the download file writer.
57 virtual bool OnReadCompleted(int bytes_read, bool* defer) override; 56 bool OnReadCompleted(int bytes_read, bool* defer) override;
58 57
59 virtual void OnResponseCompleted(const net::URLRequestStatus& status, 58 void OnResponseCompleted(const net::URLRequestStatus& status,
60 const std::string& security_info, 59 const std::string& security_info,
61 bool* defer) override; 60 bool* defer) override;
62 61
63 // N/A to this flavor of SaveFileResourceHandler. 62 // N/A to this flavor of SaveFileResourceHandler.
64 virtual void OnDataDownloaded(int bytes_downloaded) override; 63 void OnDataDownloaded(int bytes_downloaded) override;
65 64
66 // If the content-length header is not present (or contains something other 65 // If the content-length header is not present (or contains something other
67 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and 66 // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and
68 // is handled correctly by the SaveManager. 67 // is handled correctly by the SaveManager.
69 void set_content_length(const std::string& content_length); 68 void set_content_length(const std::string& content_length);
70 69
71 void set_content_disposition(const std::string& content_disposition) { 70 void set_content_disposition(const std::string& content_disposition) {
72 content_disposition_ = content_disposition; 71 content_disposition_ = content_disposition;
73 } 72 }
74 73
75 private: 74 private:
76 int save_id_; 75 int save_id_;
77 int render_process_id_; 76 int render_process_id_;
78 int render_view_id_; 77 int render_view_id_;
79 scoped_refptr<net::IOBuffer> read_buffer_; 78 scoped_refptr<net::IOBuffer> read_buffer_;
80 std::string content_disposition_; 79 std::string content_disposition_;
81 GURL url_; 80 GURL url_;
82 GURL final_url_; 81 GURL final_url_;
83 int64 content_length_; 82 int64 content_length_;
84 SaveFileManager* save_manager_; 83 SaveFileManager* save_manager_;
85 84
86 static const int kReadBufSize = 32768; // bytes 85 static const int kReadBufSize = 32768; // bytes
87 86
88 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler); 87 DISALLOW_COPY_AND_ASSIGN(SaveFileResourceHandler);
89 }; 88 };
90 89
91 } // namespace content 90 } // namespace content
92 91
93 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_ 92 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/download/mhtml_generation_manager.cc ('k') | content/browser/download/save_package.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698