OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/gcd_rest_client.h" | 5 #include "remoting/host/gcd_rest_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // | 50 // |
51 // Note that |now| is deliberately using a double to hold an integer | 51 // Note that |now| is deliberately using a double to hold an integer |
52 // value because |DictionaryValue| doesn't support int64 values, and | 52 // value because |DictionaryValue| doesn't support int64 values, and |
53 // GCD doesn't accept fractional values. | 53 // GCD doesn't accept fractional values. |
54 double now = clock_->Now().ToJavaTime(); | 54 double now = clock_->Now().ToJavaTime(); |
55 scoped_ptr<base::DictionaryValue> patch_dict(new base::DictionaryValue); | 55 scoped_ptr<base::DictionaryValue> patch_dict(new base::DictionaryValue); |
56 patch_dict->SetDouble("requestTimeMs", now); | 56 patch_dict->SetDouble("requestTimeMs", now); |
57 scoped_ptr<base::ListValue> patch_list(new base::ListValue); | 57 scoped_ptr<base::ListValue> patch_list(new base::ListValue); |
58 base::DictionaryValue* patch_item = new base::DictionaryValue; | 58 base::DictionaryValue* patch_item = new base::DictionaryValue; |
59 patch_list->Append(patch_item); | 59 patch_list->Append(patch_item); |
60 patch_item->Set("patch", patch_details.Pass()); | 60 patch_item->Set("patch", std::move(patch_details)); |
61 patch_item->SetDouble("timeMs", now); | 61 patch_item->SetDouble("timeMs", now); |
62 patch_dict->Set("patches", patch_list.Pass()); | 62 patch_dict->Set("patches", std::move(patch_list)); |
63 | 63 |
64 // Stringify the message. | 64 // Stringify the message. |
65 std::string patch_string; | 65 std::string patch_string; |
66 if (!base::JSONWriter::Write(*patch_dict, &patch_string)) { | 66 if (!base::JSONWriter::Write(*patch_dict, &patch_string)) { |
67 LOG(ERROR) << "Error building GCD device state patch."; | 67 LOG(ERROR) << "Error building GCD device state patch."; |
68 callback.Run(OTHER_ERROR); | 68 callback.Run(OTHER_ERROR); |
69 return; | 69 return; |
70 } | 70 } |
71 DLOG(INFO) << "sending state patch: " << patch_string; | 71 DLOG(INFO) << "sending state patch: " << patch_string; |
72 | 72 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 << ") fetching URL: " << request_url; | 131 << ") fetching URL: " << request_url; |
132 status = NETWORK_ERROR; | 132 status = NETWORK_ERROR; |
133 } else { | 133 } else { |
134 LOG(ERROR) << "Error (" << response << ") fetching URL: " << request_url; | 134 LOG(ERROR) << "Error (" << response << ") fetching URL: " << request_url; |
135 } | 135 } |
136 | 136 |
137 FinishCurrentRequest(status); | 137 FinishCurrentRequest(status); |
138 } | 138 } |
139 | 139 |
140 } // namespace remoting | 140 } // namespace remoting |
OLD | NEW |