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

Side by Side Diff: mock_http_fetcher.h

Issue 6677146: AU: OmahaRequestAction: allow to be skipped. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fix include "" vs <> Created 9 years, 8 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
« no previous file with comments | « no previous file | mock_http_fetcher.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_MOCK_HTTP_FETCHER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H__
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include <base/logging.h> 10 #include <base/logging.h>
(...skipping 18 matching lines...) Expand all
29 // The data passed in here is copied and then passed to the delegate after 29 // The data passed in here is copied and then passed to the delegate after
30 // the transfer begins. 30 // the transfer begins.
31 MockHttpFetcher(const char* data, 31 MockHttpFetcher(const char* data,
32 size_t size, 32 size_t size,
33 ProxyResolver* proxy_resolver) 33 ProxyResolver* proxy_resolver)
34 : HttpFetcher(proxy_resolver), 34 : HttpFetcher(proxy_resolver),
35 sent_size_(0), 35 sent_size_(0),
36 timeout_source_(NULL), 36 timeout_source_(NULL),
37 timout_tag_(0), 37 timout_tag_(0),
38 paused_(false), 38 paused_(false),
39 fail_transfer_(false) { 39 fail_transfer_(false),
40 never_use_(false) {
40 data_.insert(data_.end(), data, data + size); 41 data_.insert(data_.end(), data, data + size);
41 } 42 }
42 43
43 // Cleans up all internal state. Does not notify delegate 44 // Cleans up all internal state. Does not notify delegate
44 ~MockHttpFetcher(); 45 ~MockHttpFetcher();
45 46
46 // Ignores this. 47 // Ignores this.
47 virtual void SetOffset(off_t offset) { 48 virtual void SetOffset(off_t offset) {
48 sent_size_ = offset; 49 sent_size_ = offset;
49 if (delegate_) 50 if (delegate_)
50 delegate_->SeekToOffset(offset); 51 delegate_->SeekToOffset(offset);
51 } 52 }
52 53
53 // Begins the transfer if it hasn't already begun. 54 // Begins the transfer if it hasn't already begun.
54 virtual void BeginTransfer(const std::string& url); 55 virtual void BeginTransfer(const std::string& url);
55 56
56 // If the transfer is in progress, aborts the transfer early. 57 // If the transfer is in progress, aborts the transfer early.
57 // The transfer cannot be resumed. 58 // The transfer cannot be resumed.
58 virtual void TerminateTransfer(); 59 virtual void TerminateTransfer();
59 60
60 // Suspend the mock transfer. 61 // Suspend the mock transfer.
61 virtual void Pause(); 62 virtual void Pause();
62 63
63 // Resume the mock transfer. 64 // Resume the mock transfer.
64 virtual void Unpause(); 65 virtual void Unpause();
65 66
66 // Fail the transfer. This simulates a network failure. 67 // Fail the transfer. This simulates a network failure.
67 void FailTransfer(int http_response_code); 68 void FailTransfer(int http_response_code);
68 69
70 // If set to true, this will EXPECT fail on BeginTransfer
71 void set_never_use(bool never_use) { never_use_ = never_use; }
72
69 const std::vector<char>& post_data() const { 73 const std::vector<char>& post_data() const {
70 return post_data_; 74 return post_data_;
71 } 75 }
72 76
73 private: 77 private:
74 // Sends data to the delegate and sets up a glib timeout callback if needed. 78 // Sends data to the delegate and sets up a glib timeout callback if needed.
75 // There must be a delegate and there must be data to send. If there is 79 // There must be a delegate and there must be data to send. If there is
76 // already a timeout callback, and it should be deleted by the caller, 80 // already a timeout callback, and it should be deleted by the caller,
77 // this will return false; otherwise true is returned. 81 // this will return false; otherwise true is returned.
78 // If skip_delivery is true, no bytes will be delivered, but the callbacks 82 // If skip_delivery is true, no bytes will be delivered, but the callbacks
(...skipping 22 matching lines...) Expand all
101 105
102 // ID of the timeout source, valid only if timeout_source_ != NULL 106 // ID of the timeout source, valid only if timeout_source_ != NULL
103 guint timout_tag_; 107 guint timout_tag_;
104 108
105 // True iff the fetcher is paused. 109 // True iff the fetcher is paused.
106 bool paused_; 110 bool paused_;
107 111
108 // Set to true if the transfer should fail. 112 // Set to true if the transfer should fail.
109 bool fail_transfer_; 113 bool fail_transfer_;
110 114
115 // Set to true if BeginTransfer should EXPECT fail.
116 bool never_use_;
117
111 DISALLOW_COPY_AND_ASSIGN(MockHttpFetcher); 118 DISALLOW_COPY_AND_ASSIGN(MockHttpFetcher);
112 }; 119 };
113 120
114 } // namespace chromeos_update_engine 121 } // namespace chromeos_update_engine
115 122
116 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H__ 123 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HTTP_FETCHER_H__
OLDNEW
« no previous file with comments | « no previous file | mock_http_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698