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

Side by Side Diff: chrome/common/net/test_url_fetcher_factory.h

Issue 6615020: Stream speech audio to server as it gets recorded, instead of waiting until end of recording. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 5 #ifndef CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
6 #define CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 6 #define CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class TestURLFetcher : public URLFetcher { 44 class TestURLFetcher : public URLFetcher {
45 public: 45 public:
46 TestURLFetcher(int id, 46 TestURLFetcher(int id,
47 const GURL& url, 47 const GURL& url,
48 RequestType request_type, 48 RequestType request_type,
49 Delegate* d); 49 Delegate* d);
50 50
51 // Overriden to do nothing. It is assumed the caller will notify the delegate. 51 // Overriden to do nothing. It is assumed the caller will notify the delegate.
52 virtual void Start() {} 52 virtual void Start() {}
53 53
54 // Overriden to cache the chunks uploaded. Caller can read back the uploaded
55 // chunks with the upload_data() accessor.
56 virtual void AppendChunkToUpload(const std::string& data, bool is_last_chunk);
57
54 // Unique ID in our factory. 58 // Unique ID in our factory.
55 int id() const { return id_; } 59 int id() const { return id_; }
56 60
57 // URL we were created with. Because of how we're using URLFetcher url() 61 // URL we were created with. Because of how we're using URLFetcher url()
58 // always returns an empty URL. Chances are you'll want to use original_url() 62 // always returns an empty URL. Chances are you'll want to use original_url()
59 // in your tests. 63 // in your tests.
60 const GURL& original_url() const { return original_url_; } 64 const GURL& original_url() const { return original_url_; }
61 65
62 // Returns the data uploaded on this URLFetcher. 66 // Returns the data uploaded on this URLFetcher.
63 const std::string& upload_data() const { return URLFetcher::upload_data(); } 67 const std::string& upload_data() const { return URLFetcher::upload_data(); }
64 68
69 // Returns the chunks of data uploaded on this URLFetcher.
70 const std::list<std::string>& upload_chunks() const { return chunks_; }
71
65 // Returns the delegate installed on the URLFetcher. 72 // Returns the delegate installed on the URLFetcher.
66 Delegate* delegate() const { return URLFetcher::delegate(); } 73 Delegate* delegate() const { return URLFetcher::delegate(); }
67 74
68 private: 75 private:
69 const int id_; 76 const int id_;
70 const GURL original_url_; 77 const GURL original_url_;
78 std::list<std::string> chunks_;
79 bool did_receive_last_chunk_;
71 80
72 DISALLOW_COPY_AND_ASSIGN(TestURLFetcher); 81 DISALLOW_COPY_AND_ASSIGN(TestURLFetcher);
73 }; 82 };
74 83
75 // Simple URLFetcher::Factory method that creates TestURLFetchers. All fetchers 84 // Simple URLFetcher::Factory method that creates TestURLFetchers. All fetchers
76 // are registered in a map by the id passed to the create method. 85 // are registered in a map by the id passed to the create method.
77 class TestURLFetcherFactory : public URLFetcher::Factory { 86 class TestURLFetcherFactory : public URLFetcher::Factory {
78 public: 87 public:
79 TestURLFetcherFactory(); 88 TestURLFetcherFactory();
80 virtual ~TestURLFetcherFactory(); 89 virtual ~TestURLFetcherFactory();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void ClearFakeReponses(); 160 void ClearFakeReponses();
152 161
153 private: 162 private:
154 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap; 163 typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap;
155 FakeResponseMap fake_responses_; 164 FakeResponseMap fake_responses_;
156 165
157 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory); 166 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory);
158 }; 167 };
159 168
160 #endif // CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 169 #endif // CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/common/net/test_url_fetcher_factory.cc » ('j') | chrome/common/net/url_fetcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698