Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // Used to unpause an HttpFetcher and let the bytes stream in again. | 79 // Used to unpause an HttpFetcher and let the bytes stream in again. |
| 80 // If a delegate is set, ReceivedBytes() may be called on it before | 80 // If a delegate is set, ReceivedBytes() may be called on it before |
| 81 // Unpause() returns | 81 // Unpause() returns |
| 82 virtual void Unpause() = 0; | 82 virtual void Unpause() = 0; |
| 83 | 83 |
| 84 // These two function are overloaded in LibcurlHttp fetcher to speed | 84 // These two function are overloaded in LibcurlHttp fetcher to speed |
| 85 // testing. | 85 // testing. |
| 86 virtual void set_idle_seconds(int seconds) {} | 86 virtual void set_idle_seconds(int seconds) {} |
| 87 virtual void set_retry_seconds(int seconds) {} | 87 virtual void set_retry_seconds(int seconds) {} |
| 88 | 88 |
| 89 ProxyResolver* proxy_resolver() const { return proxy_resolver_; } | |
| 90 | |
| 91 virtual void SetConnectionAsExpensive(bool is_expensive) {} | |
|
petkov
2010/12/16 18:30:57
Maybe add a comment that these methods are used fo
adlr
2010/12/17 01:03:51
Done.
| |
| 92 virtual void SetBuildType(bool is_official) {} | |
| 93 | |
| 89 protected: | 94 protected: |
| 90 // The URL we're actively fetching from | 95 // The URL we're actively fetching from |
| 91 std::string url_; | 96 std::string url_; |
| 92 | 97 |
| 93 // POST data for the transfer, and whether or not it was ever set | 98 // POST data for the transfer, and whether or not it was ever set |
| 94 bool post_data_set_; | 99 bool post_data_set_; |
| 95 std::vector<char> post_data_; | 100 std::vector<char> post_data_; |
| 96 | 101 |
| 97 // The server's HTTP response code from the last transfer. This | 102 // The server's HTTP response code from the last transfer. This |
| 98 // field should be set to 0 when a new transfer is initiated, and | 103 // field should be set to 0 when a new transfer is initiated, and |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 115 class HttpFetcherDelegate { | 120 class HttpFetcherDelegate { |
| 116 public: | 121 public: |
| 117 // Called every time bytes are received. | 122 // Called every time bytes are received. |
| 118 virtual void ReceivedBytes(HttpFetcher* fetcher, | 123 virtual void ReceivedBytes(HttpFetcher* fetcher, |
| 119 const char* bytes, | 124 const char* bytes, |
| 120 int length) = 0; | 125 int length) = 0; |
| 121 | 126 |
| 122 // Called if the fetcher seeks to a particular offset. | 127 // Called if the fetcher seeks to a particular offset. |
| 123 virtual void SeekToOffset(off_t offset) {} | 128 virtual void SeekToOffset(off_t offset) {} |
| 124 | 129 |
| 130 // When a transfer has completed, exactly one of these two methods will be | |
|
petkov
2010/12/16 18:30:57
You may want to combine the docstrings for the two
adlr
2010/12/17 01:03:51
Done.
| |
| 131 // called: | |
| 132 | |
| 125 // Called when the transfer has completed successfully or been aborted through | 133 // Called when the transfer has completed successfully or been aborted through |
| 126 // means other than TerminateTransfer. It's OK to destroy the |fetcher| object | 134 // means other than TerminateTransfer. It's OK to destroy the |fetcher| object |
| 127 // in this callback. | 135 // in this callback. |
| 128 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0; | 136 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0; |
|
petkov
2010/12/16 18:30:57
Side note: Chrome has a convention to use "OnEvent
adlr
2010/12/17 01:03:51
That's a good idea. I'll make a note to update our
| |
| 129 | 137 |
| 130 // Called when the transfer has been aborted through TerminateTransfer. It's | 138 // Called when the transfer has been aborted through TerminateTransfer. It's |
| 131 // OK to destroy the |fetcher| object in this callback. | 139 // OK to destroy the |fetcher| object in this callback. |
| 132 virtual void TransferTerminated(HttpFetcher* fetcher) {} | 140 virtual void TransferTerminated(HttpFetcher* fetcher) {} |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 } // namespace chromeos_update_engine | 143 } // namespace chromeos_update_engine |
| 136 | 144 |
| 137 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ | 145 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ |
| OLD | NEW |