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

Side by Side Diff: http_fetcher.h

Issue 5009009: AU: Fix potential issues with premature destruction of HTTP fetchers. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years, 1 month 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 | « download_action_unittest.cc ('k') | http_fetcher_unittest.cc » ('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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <glib.h> 10 #include <glib.h>
(...skipping 27 matching lines...) Expand all
38 void SetPostData(const void* data, size_t size) { 38 void SetPostData(const void* data, size_t size) {
39 post_data_set_ = true; 39 post_data_set_ = true;
40 post_data_.clear(); 40 post_data_.clear();
41 const char *char_data = reinterpret_cast<const char*>(data); 41 const char *char_data = reinterpret_cast<const char*>(data);
42 post_data_.insert(post_data_.end(), char_data, char_data + size); 42 post_data_.insert(post_data_.end(), char_data, char_data + size);
43 } 43 }
44 44
45 // Downloading should resume from this offset 45 // Downloading should resume from this offset
46 virtual void SetOffset(off_t offset) = 0; 46 virtual void SetOffset(off_t offset) = 0;
47 47
48 // Begins the transfer to the specified URL. 48 // Begins the transfer to the specified URL. This fetcher instance should not
49 // be destroyed until either TransferComplete, or TransferTerminated is
50 // called.
49 virtual void BeginTransfer(const std::string& url) = 0; 51 virtual void BeginTransfer(const std::string& url) = 0;
50 52
51 // Aborts the transfer. TransferComplete() will not be called on the 53 // Aborts the transfer. The transfer may not abort right away -- delegate's
52 // delegate. 54 // TransferTerminated() will be called when the transfer is actually done.
53 virtual void TerminateTransfer() = 0; 55 virtual void TerminateTransfer() = 0;
54 56
55 // If data is coming in too quickly, you can call Pause() to pause the 57 // If data is coming in too quickly, you can call Pause() to pause the
56 // transfer. The delegate will not have ReceivedBytes() called while 58 // transfer. The delegate will not have ReceivedBytes() called while
57 // an HttpFetcher is paused. 59 // an HttpFetcher is paused.
58 virtual void Pause() = 0; 60 virtual void Pause() = 0;
59 61
60 // Used to unpause an HttpFetcher and let the bytes stream in again. 62 // Used to unpause an HttpFetcher and let the bytes stream in again.
61 // If a delegate is set, ReceivedBytes() may be called on it before 63 // If a delegate is set, ReceivedBytes() may be called on it before
62 // Unpause() returns 64 // Unpause() returns
(...skipping 27 matching lines...) Expand all
90 class HttpFetcherDelegate { 92 class HttpFetcherDelegate {
91 public: 93 public:
92 // Called every time bytes are received. 94 // Called every time bytes are received.
93 virtual void ReceivedBytes(HttpFetcher* fetcher, 95 virtual void ReceivedBytes(HttpFetcher* fetcher,
94 const char* bytes, 96 const char* bytes,
95 int length) = 0; 97 int length) = 0;
96 98
97 // Called if the fetcher seeks to a particular offset. 99 // Called if the fetcher seeks to a particular offset.
98 virtual void SeekToOffset(off_t offset) {} 100 virtual void SeekToOffset(off_t offset) {}
99 101
100 // Called when the transfer has completed successfully or been somehow 102 // Called when the transfer has completed successfully or been aborted through
101 // aborted. 103 // means other than TerminateTransfer. It's OK to destroy the |fetcher| object
104 // in this callback.
102 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0; 105 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0;
106
107 // Called when the transfer has been aborted through TerminateTransfer. It's
108 // OK to destroy the |fetcher| object in this callback.
109 virtual void TransferTerminated(HttpFetcher* fetcher) {}
103 }; 110 };
104 111
105 } // namespace chromeos_update_engine 112 } // namespace chromeos_update_engine
106 113
107 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ 114 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__
OLDNEW
« no previous file with comments | « download_action_unittest.cc ('k') | http_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698