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

Side by Side Diff: sync/internal_api/http_post_provider_interface.h

Issue 10534080: sync: move internal_api components used by chrome/browser into internal_api/public (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 6 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SYNC_INTERNAL_API_HTTP_POST_PROVIDER_INTERFACE_H_
6 #define SYNC_INTERNAL_API_HTTP_POST_PROVIDER_INTERFACE_H_
7 #pragma once
8
9 #include <string>
10
11 namespace sync_api {
12
13 // An interface the embedding application (e.g. Chromium) implements to provide
14 // required HTTP POST functionality to the syncer backend. This interface is
15 // designed for one-time use. You create one, use it, and create another if you
16 // want to make a subsequent POST.
17 class HttpPostProviderInterface {
18 public:
19 // Use specified user agent string when POSTing. If not called a default UA
20 // may be used.
21 virtual void SetUserAgent(const char* user_agent) = 0;
22
23 // Add additional headers to the request.
24 virtual void SetExtraRequestHeaders(const char* headers) = 0;
25
26 // Set the URL to POST to.
27 virtual void SetURL(const char* url, int port) = 0;
28
29 // Set the type, length and content of the POST payload.
30 // |content_type| is a null-terminated MIME type specifier.
31 // |content| is a data buffer; Do not interpret as a null-terminated string.
32 // |content_length| is the total number of chars in |content|. It is used to
33 // assign/copy |content| data.
34 virtual void SetPostPayload(const char* content_type,
35 int content_length,
36 const char* content) = 0;
37
38 // Returns true if the URL request succeeded. If the request failed,
39 // error() may be non-zero and hence contain more information.
40 virtual bool MakeSynchronousPost(int* error_code, int* response_code) = 0;
41
42 // Get the length of the content returned in the HTTP response.
43 // This does not count the trailing null-terminating character returned
44 // by GetResponseContent, so it is analogous to calling string.length.
45 virtual int GetResponseContentLength() const = 0;
46
47 // Get the content returned in the HTTP response.
48 // This is a null terminated string of characters.
49 // Value should be copied.
50 virtual const char* GetResponseContent() const = 0;
51
52 // Get the value of a header returned in the HTTP response.
53 // If the header is not present, returns the empty string.
54 virtual const std::string GetResponseHeaderValue(
55 const std::string& name) const = 0;
56
57 // Abandon any pending POST and unblock caller in MakeSynchronousPost.
58 // This must be safe to call from any thread.
59 virtual void Abort() = 0;
60
61 protected:
62 virtual ~HttpPostProviderInterface() {}
63 };
64
65 } // namespace sync_api
66
67 #endif // SYNC_INTERNAL_API_HTTP_POST_PROVIDER_INTERFACE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/http_post_provider_factory.h ('k') | sync/internal_api/js_mutation_event_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698