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

Side by Side Diff: blimp/common/logging.cc

Issue 2091023006: Adds EngineGeolocationFeature for Blimp Geolocation project. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 4 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
« no previous file with comments | « blimp/common/create_blimp_message.cc ('k') | blimp/common/proto/BUILD.gn » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/common/logging.h" 5 #include "blimp/common/logging.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 message.blob_channel().transfer_blob().blob_id().size()), 293 message.blob_channel().transfer_blob().blob_id().size()),
294 output); 294 output);
295 AddField("payload_size", 295 AddField("payload_size",
296 message.blob_channel().transfer_blob().payload().size(), output); 296 message.blob_channel().transfer_blob().payload().size(), output);
297 break; 297 break;
298 case BlobChannelMessage::TypeCase::TYPE_NOT_SET: // unknown 298 case BlobChannelMessage::TypeCase::TYPE_NOT_SET: // unknown
299 break; 299 break;
300 } 300 }
301 } 301 }
302 302
303 // Logs fields from GEOLOCATION messages.
304 void ExtractGeolocationMessageFields(const BlimpMessage& message,
305 LogFields* output) {
306 switch (message.geolocation().type_case()) {
307 case GeolocationMessage::TypeCase::kSetInterestLevel:
308 AddField("subtype", "SET_INTEREST_LEVEL", output);
309 AddField("level", message.geolocation().set_interest_level().level(),
310 output);
311 break;
312 case GeolocationMessage::TypeCase::kRequestRefresh:
313 AddField("subtype", "REQUEST_REFRESH", output);
314 break;
315 case GeolocationMessage::TypeCase::kCoordinates: {
316 const GeolocationCoordinatesMessage& coordinates =
317 message.geolocation().coordinates();
318 AddField("subtype", "COORDINATES", output);
319 AddField("latitude", coordinates.latitude(), output);
320 AddField("longitude", coordinates.longitude(), output);
321 AddField("altitude", coordinates.altitude(), output);
322 AddField("accuracy", coordinates.accuracy(), output);
323 AddField("altitude_accuracy", coordinates.altitude_accuracy(), output);
324 AddField("heading", coordinates.heading(), output);
325 AddField("speed", coordinates.speed(), output);
326 break;
327 }
328 case GeolocationMessage::TypeCase::kError:
329 AddField("subtype", "ERROR", output);
330 AddField("error_code", message.geolocation().error().error_code(),
331 output);
332 AddField("error_message", message.geolocation().error().error_message(),
333 output);
334 break;
335 case GeolocationMessage::TypeCase::TYPE_NOT_SET:
336 break;
337 }
338 }
339
303 } // namespace 340 } // namespace
304 341
305 std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) { 342 std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) {
306 LogFields fields; 343 LogFields fields;
307 344
308 switch (message.feature_case()) { 345 switch (message.feature_case()) {
309 case BlimpMessage::kCompositor: 346 case BlimpMessage::kCompositor:
310 AddField("type", "COMPOSITOR", &fields); 347 AddField("type", "COMPOSITOR", &fields);
311 ExtractCompositorMessageFields(message, &fields); 348 ExtractCompositorMessageFields(message, &fields);
312 break; 349 break;
(...skipping 22 matching lines...) Expand all
335 ExtractTabControlMessageFields(message, &fields); 372 ExtractTabControlMessageFields(message, &fields);
336 break; 373 break;
337 case BlimpMessage::kBlobChannel: 374 case BlimpMessage::kBlobChannel:
338 AddField("type", "BLOB_CHANNEL", &fields); 375 AddField("type", "BLOB_CHANNEL", &fields);
339 ExtractBlobChannelMessageFields(message, &fields); 376 ExtractBlobChannelMessageFields(message, &fields);
340 break; 377 break;
341 case BlimpMessage::kIme: 378 case BlimpMessage::kIme:
342 AddField("type", "IME", &fields); 379 AddField("type", "IME", &fields);
343 ExtractImeMessageFields(message, &fields); 380 ExtractImeMessageFields(message, &fields);
344 break; 381 break;
382 case BlimpMessage::kGeolocation:
383 AddField("type", "GEOLOCATION", &fields);
384 ExtractGeolocationMessageFields(message, &fields);
385 break;
345 case BlimpMessage::FEATURE_NOT_SET: 386 case BlimpMessage::FEATURE_NOT_SET:
346 AddField("type", "<UNKNOWN>", &fields); 387 AddField("type", "<UNKNOWN>", &fields);
347 break; 388 break;
348 } 389 }
349 390
350 // Append "target_tab_id" (if present) and "byte_size" to the field set. 391 // Append "target_tab_id" (if present) and "byte_size" to the field set.
351 if (message.has_target_tab_id()) { 392 if (message.has_target_tab_id()) {
352 AddField("target_tab_id", message.target_tab_id(), &fields); 393 AddField("target_tab_id", message.target_tab_id(), &fields);
353 } 394 }
354 AddField("byte_size", message.ByteSize(), &fields); 395 AddField("byte_size", message.ByteSize(), &fields);
355 396
356 // Format message using the syntax: 397 // Format message using the syntax:
357 // <BlimpMessage field1=value1 field2="value 2"> 398 // <BlimpMessage field1=value1 field2="value 2">
358 out << "<BlimpMessage "; 399 out << "<BlimpMessage ";
359 for (size_t i = 0; i < fields.size(); ++i) { 400 for (size_t i = 0; i < fields.size(); ++i) {
360 out << fields[i].first << "=" << fields[i].second 401 out << fields[i].first << "=" << fields[i].second
361 << (i != fields.size() - 1 ? " " : ""); 402 << (i != fields.size() - 1 ? " " : "");
362 } 403 }
363 out << ">"; 404 out << ">";
364 405
365 return out; 406 return out;
366 } 407 }
367 408
368 } // namespace blimp 409 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/common/create_blimp_message.cc ('k') | blimp/common/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698