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

Side by Side Diff: components/copresence/rpc/http_post.cc

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/copresence/rpc/http_post.h" 5 #include "components/copresence/rpc/http_post.h"
6 6
7 // TODO(ckehoe): Support third-party protobufs too. 7 // TODO(ckehoe): Support third-party protobufs too.
8 #include <google/protobuf/message_lite.h> 8 #include <google/protobuf/message_lite.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 url = net::AppendQueryParameter(url, kApiKeyField, api_key); 52 url = net::AppendQueryParameter(url, kApiKeyField, api_key);
53 } 53 }
54 54
55 // Serialize the proto for transmission. 55 // Serialize the proto for transmission.
56 std::string request_data; 56 std::string request_data;
57 bool serialize_success = request_proto.SerializeToString(&request_data); 57 bool serialize_success = request_proto.SerializeToString(&request_data);
58 DCHECK(serialize_success); 58 DCHECK(serialize_success);
59 59
60 // Configure and send the request. 60 // Configure and send the request.
61 url_fetcher_.reset(net::URLFetcher::Create( 61 url_fetcher_ =
62 kUrlFetcherId, url, net::URLFetcher::POST, this)); 62 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this);
63 url_fetcher_->SetRequestContext(url_context_getter); 63 url_fetcher_->SetRequestContext(url_context_getter);
64 url_fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | 64 url_fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE |
65 net::LOAD_DISABLE_CACHE | 65 net::LOAD_DISABLE_CACHE |
66 net::LOAD_DO_NOT_SAVE_COOKIES | 66 net::LOAD_DO_NOT_SAVE_COOKIES |
67 net::LOAD_DO_NOT_SEND_COOKIES | 67 net::LOAD_DO_NOT_SEND_COOKIES |
68 net::LOAD_DO_NOT_SEND_AUTH_DATA); 68 net::LOAD_DO_NOT_SEND_AUTH_DATA);
69 url_fetcher_->SetUploadData("application/x-protobuf", request_data); 69 url_fetcher_->SetUploadData("application/x-protobuf", request_data);
70 if (!auth_token.empty()) { 70 if (!auth_token.empty()) {
71 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " + auth_token); 71 url_fetcher_->AddExtraRequestHeader("Authorization: Bearer " + auth_token);
72 } 72 }
(...skipping 27 matching lines...) Expand all
100 } else if (response_code != net::HTTP_OK) { 100 } else if (response_code != net::HTTP_OK) {
101 LOG(WARNING) << "Copresence request got HTTP response code " 101 LOG(WARNING) << "Copresence request got HTTP response code "
102 << response_code << ". Response:\n" << response; 102 << response_code << ". Response:\n" << response;
103 } 103 }
104 104
105 // Return the response. 105 // Return the response.
106 response_callback_.Run(response_code, response); 106 response_callback_.Run(response_code, response);
107 } 107 }
108 108
109 } // namespace copresence 109 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698