| 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 UPDATE_ENGINE_HTTP_FETCHER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ |
| 6 #define 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 <glib.h> | 10 #include <glib.h> |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 | 12 |
| 12 // This class is a simple wrapper around an HTTP library (libcurl). We can | 13 // This class is a simple wrapper around an HTTP library (libcurl). We can |
| 13 // easily mock out this interface for testing. | 14 // easily mock out this interface for testing. |
| 14 | 15 |
| 15 // Implementations of this class should use asynchronous i/o. They can access | 16 // Implementations of this class should use asynchronous i/o. They can access |
| 16 // the glib main loop to request callbacks when timers or file descriptors | 17 // the glib main loop to request callbacks when timers or file descriptors |
| 17 // change. | 18 // change. |
| 18 | 19 |
| 19 namespace chromeos_update_engine { | 20 namespace chromeos_update_engine { |
| 20 | 21 |
| 21 class HttpFetcherDelegate; | 22 class HttpFetcherDelegate; |
| 22 | 23 |
| 23 class HttpFetcher { | 24 class HttpFetcher { |
| 24 public: | 25 public: |
| 25 HttpFetcher() : delegate_(NULL) {} | 26 HttpFetcher() : post_data_set_(false), delegate_(NULL) {} |
| 26 virtual ~HttpFetcher() {} | 27 virtual ~HttpFetcher() {} |
| 27 void set_delegate(HttpFetcherDelegate* delegate) { | 28 void set_delegate(HttpFetcherDelegate* delegate) { |
| 28 delegate_ = delegate; | 29 delegate_ = delegate; |
| 29 } | 30 } |
| 30 HttpFetcherDelegate* delegate() const { | 31 HttpFetcherDelegate* delegate() const { |
| 31 return delegate_; | 32 return delegate_; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Optional: Post data to the server. The HttpFetcher should make a copy | 35 // Optional: Post data to the server. The HttpFetcher should make a copy |
| 35 // of this data and upload it via HTTP POST during the transfer. | 36 // of this data and upload it via HTTP POST during the transfer. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 const char* bytes, | 81 const char* bytes, |
| 81 int length) = 0; | 82 int length) = 0; |
| 82 | 83 |
| 83 // Called when the transfer has completed successfully or been somehow | 84 // Called when the transfer has completed successfully or been somehow |
| 84 // aborted. | 85 // aborted. |
| 85 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0; | 86 virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0; |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 } // namespace chromeos_update_engine | 89 } // namespace chromeos_update_engine |
| 89 | 90 |
| 90 #endif // UPDATE_ENGINE_HTTP_FETCHER_H__ | 91 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_FETCHER_H__ |
| OLD | NEW |