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

Side by Side Diff: chromeos/dbus/bluetooth_agent_service_provider.cc

Issue 12092061: Code cleaning: Uses scoped_ptr<> to express ownership rather than writing ownership in comments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added chrome/browser/password_manager/native_backend_kwallet_x_unitte\ Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 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 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 "chromeos/dbus/bluetooth_agent_service_provider.h" 5 #include "chromeos/dbus/bluetooth_agent_service_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/chromeos/chromeos_version.h" 10 #include "base/chromeos/chromeos_version.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 // Called by dbus:: when the agent is unregistered from the Bluetooth 133 // Called by dbus:: when the agent is unregistered from the Bluetooth
134 // daemon, generally at the end of a pairing request. 134 // daemon, generally at the end of a pairing request.
135 void Release(dbus::MethodCall* method_call, 135 void Release(dbus::MethodCall* method_call,
136 dbus::ExportedObject::ResponseSender response_sender) { 136 dbus::ExportedObject::ResponseSender response_sender) {
137 DCHECK(OnOriginThread()); 137 DCHECK(OnOriginThread());
138 DCHECK(delegate_); 138 DCHECK(delegate_);
139 139
140 delegate_->Release(); 140 delegate_->Release();
141 141
142 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 142 response_sender.Run(dbus::Response::FromMethodCall(method_call));
143 response_sender.Run(response);
144 } 143 }
145 144
146 // Called by dbus:: when the Release method is exported. 145 // Called by dbus:: when the Release method is exported.
147 void ReleaseExported(const std::string& interface_name, 146 void ReleaseExported(const std::string& interface_name,
148 const std::string& method_name, 147 const std::string& method_name,
149 bool success) { 148 bool success) {
150 LOG_IF(WARNING, !success) << "Failed to export " 149 LOG_IF(WARNING, !success) << "Failed to export "
151 << interface_name << "." << method_name; 150 << interface_name << "." << method_name;
152 } 151 }
153 152
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 std::string pincode; 227 std::string pincode;
229 if (!reader.PopObjectPath(&device_path) || 228 if (!reader.PopObjectPath(&device_path) ||
230 !reader.PopString(&pincode)) { 229 !reader.PopString(&pincode)) {
231 LOG(WARNING) << "DisplayPinCode called with incorrect paramters: " 230 LOG(WARNING) << "DisplayPinCode called with incorrect paramters: "
232 << method_call->ToString(); 231 << method_call->ToString();
233 return; 232 return;
234 } 233 }
235 234
236 delegate_->DisplayPinCode(device_path, pincode); 235 delegate_->DisplayPinCode(device_path, pincode);
237 236
238 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 237 response_sender.Run(dbus::Response::FromMethodCall(method_call));
239 response_sender.Run(response);
240 } 238 }
241 239
242 // Called by dbus:: when the DisplayPinCode method is exported. 240 // Called by dbus:: when the DisplayPinCode method is exported.
243 void DisplayPinCodeExported(const std::string& interface_name, 241 void DisplayPinCodeExported(const std::string& interface_name,
244 const std::string& method_name, 242 const std::string& method_name,
245 bool success) { 243 bool success) {
246 LOG_IF(WARNING, !success) << "Failed to export " 244 LOG_IF(WARNING, !success) << "Failed to export "
247 << interface_name << "." << method_name; 245 << interface_name << "." << method_name;
248 } 246 }
249 247
(...skipping 10 matching lines...) Expand all
260 uint32 passkey; 258 uint32 passkey;
261 if (!reader.PopObjectPath(&device_path) || 259 if (!reader.PopObjectPath(&device_path) ||
262 !reader.PopUint32(&passkey)) { 260 !reader.PopUint32(&passkey)) {
263 LOG(WARNING) << "DisplayPasskey called with incorrect paramters: " 261 LOG(WARNING) << "DisplayPasskey called with incorrect paramters: "
264 << method_call->ToString(); 262 << method_call->ToString();
265 return; 263 return;
266 } 264 }
267 265
268 delegate_->DisplayPasskey(device_path, passkey); 266 delegate_->DisplayPasskey(device_path, passkey);
269 267
270 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 268 response_sender.Run(dbus::Response::FromMethodCall(method_call));
271 response_sender.Run(response);
272 } 269 }
273 270
274 // Called by dbus:: when the DisplayPasskey method is exported. 271 // Called by dbus:: when the DisplayPasskey method is exported.
275 void DisplayPasskeyExported(const std::string& interface_name, 272 void DisplayPasskeyExported(const std::string& interface_name,
276 const std::string& method_name, 273 const std::string& method_name,
277 bool success) { 274 bool success) {
278 LOG_IF(WARNING, !success) << "Failed to export " 275 LOG_IF(WARNING, !success) << "Failed to export "
279 << interface_name << "." << method_name; 276 << interface_name << "." << method_name;
280 } 277 }
281 278
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 394
398 // Called by dbus:: when the request failed before a reply was returned 395 // Called by dbus:: when the request failed before a reply was returned
399 // from the device. 396 // from the device.
400 void Cancel(dbus::MethodCall* method_call, 397 void Cancel(dbus::MethodCall* method_call,
401 dbus::ExportedObject::ResponseSender response_sender) { 398 dbus::ExportedObject::ResponseSender response_sender) {
402 DCHECK(OnOriginThread()); 399 DCHECK(OnOriginThread());
403 DCHECK(delegate_); 400 DCHECK(delegate_);
404 401
405 delegate_->Cancel(); 402 delegate_->Cancel();
406 403
407 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 404 response_sender.Run(dbus::Response::FromMethodCall(method_call));
408 response_sender.Run(response);
409 } 405 }
410 406
411 // Called by dbus:: when the Cancel method is exported. 407 // Called by dbus:: when the Cancel method is exported.
412 void CancelExported(const std::string& interface_name, 408 void CancelExported(const std::string& interface_name,
413 const std::string& method_name, 409 const std::string& method_name,
414 bool success) { 410 bool success) {
415 LOG_IF(WARNING, !success) << "Failed to export " 411 LOG_IF(WARNING, !success) << "Failed to export "
416 << interface_name << "." << method_name; 412 << interface_name << "." << method_name;
417 } 413 }
418 414
419 // Called by the Delegate to response to a method requesting a PIN code. 415 // Called by the Delegate to response to a method requesting a PIN code.
420 void OnPinCode(dbus::MethodCall* method_call, 416 void OnPinCode(dbus::MethodCall* method_call,
421 dbus::ExportedObject::ResponseSender response_sender, 417 dbus::ExportedObject::ResponseSender response_sender,
422 Delegate::Status status, 418 Delegate::Status status,
423 const std::string& pincode) { 419 const std::string& pincode) {
424 DCHECK(OnOriginThread()); 420 DCHECK(OnOriginThread());
425 421
426 switch (status) { 422 switch (status) {
427 case Delegate::SUCCESS: { 423 case Delegate::SUCCESS: {
428 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 424 scoped_ptr<dbus::Response> response(
429 dbus::MessageWriter writer(response); 425 dbus::Response::FromMethodCall(method_call));
426 dbus::MessageWriter writer(response.get());
430 writer.AppendString(pincode); 427 writer.AppendString(pincode);
431 response_sender.Run(response); 428 response_sender.Run(response.Pass());
432 break; 429 break;
433 } 430 }
434 case Delegate::REJECTED: { 431 case Delegate::REJECTED: {
435 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 432 response_sender.Run(
436 method_call, bluetooth_agent::kErrorRejected, "rejected"); 433 dbus::ErrorResponse::FromMethodCall(
437 response_sender.Run(response); 434 method_call, bluetooth_agent::kErrorRejected, "rejected")
435 .PassAs<dbus::Response>());
438 break; 436 break;
439 } 437 }
440 case Delegate::CANCELLED: { 438 case Delegate::CANCELLED: {
441 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 439 response_sender.Run(
442 method_call, bluetooth_agent::kErrorCanceled, "canceled"); 440 dbus::ErrorResponse::FromMethodCall(
443 response_sender.Run(response); 441 method_call, bluetooth_agent::kErrorCanceled, "canceled")
442 .PassAs<dbus::Response>());
444 break; 443 break;
445 } 444 }
446 default: 445 default:
447 NOTREACHED() << "Unexpected status code from delegate: " << status; 446 NOTREACHED() << "Unexpected status code from delegate: " << status;
448 } 447 }
449 } 448 }
450 449
451 // Called by the Delegate to response to a method requesting a Passkey. 450 // Called by the Delegate to response to a method requesting a Passkey.
452 void OnPasskey(dbus::MethodCall* method_call, 451 void OnPasskey(dbus::MethodCall* method_call,
453 dbus::ExportedObject::ResponseSender response_sender, 452 dbus::ExportedObject::ResponseSender response_sender,
454 Delegate::Status status, 453 Delegate::Status status,
455 uint32 passkey) { 454 uint32 passkey) {
456 DCHECK(OnOriginThread()); 455 DCHECK(OnOriginThread());
457 456
458 switch (status) { 457 switch (status) {
459 case Delegate::SUCCESS: { 458 case Delegate::SUCCESS: {
460 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 459 scoped_ptr<dbus::Response> response(
461 dbus::MessageWriter writer(response); 460 dbus::Response::FromMethodCall(method_call));
461 dbus::MessageWriter writer(response.get());
462 writer.AppendUint32(passkey); 462 writer.AppendUint32(passkey);
463 response_sender.Run(response); 463 response_sender.Run(response.Pass());
464 break; 464 break;
465 } 465 }
466 case Delegate::REJECTED: { 466 case Delegate::REJECTED: {
467 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 467 response_sender.Run(
468 method_call, bluetooth_agent::kErrorRejected, "rejected"); 468 dbus::ErrorResponse::FromMethodCall(
469 response_sender.Run(response); 469 method_call, bluetooth_agent::kErrorRejected, "rejected")
470 .PassAs<dbus::Response>());
470 break; 471 break;
471 } 472 }
472 case Delegate::CANCELLED: { 473 case Delegate::CANCELLED: {
473 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 474 response_sender.Run(
474 method_call, bluetooth_agent::kErrorCanceled, "canceled"); 475 dbus::ErrorResponse::FromMethodCall(
475 response_sender.Run(response); 476 method_call, bluetooth_agent::kErrorCanceled, "canceled")
477 .PassAs<dbus::Response>());
476 break; 478 break;
477 } 479 }
478 default: 480 default:
479 NOTREACHED() << "Unexpected status code from delegate: " << status; 481 NOTREACHED() << "Unexpected status code from delegate: " << status;
480 } 482 }
481 } 483 }
482 484
483 // Called by the Delegate in response to a method requiring confirmation. 485 // Called by the Delegate in response to a method requiring confirmation.
484 void OnConfirmation(dbus::MethodCall* method_call, 486 void OnConfirmation(dbus::MethodCall* method_call,
485 dbus::ExportedObject::ResponseSender response_sender, 487 dbus::ExportedObject::ResponseSender response_sender,
486 Delegate::Status status) { 488 Delegate::Status status) {
487 DCHECK(OnOriginThread()); 489 DCHECK(OnOriginThread());
488 490
489 switch (status) { 491 switch (status) {
490 case Delegate::SUCCESS: { 492 case Delegate::SUCCESS: {
491 dbus::Response* response = dbus::Response::FromMethodCall(method_call); 493 response_sender.Run(dbus::Response::FromMethodCall(method_call));
492 response_sender.Run(response);
493 break; 494 break;
494 } 495 }
495 case Delegate::REJECTED: { 496 case Delegate::REJECTED: {
496 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 497 response_sender.Run(
497 method_call, bluetooth_agent::kErrorRejected, "rejected"); 498 dbus::ErrorResponse::FromMethodCall(
498 response_sender.Run(response); 499 method_call, bluetooth_agent::kErrorRejected, "rejected")
500 .PassAs<dbus::Response>());
499 break; 501 break;
500 } 502 }
501 case Delegate::CANCELLED: { 503 case Delegate::CANCELLED: {
502 dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall( 504 response_sender.Run(
503 method_call, bluetooth_agent::kErrorCanceled, "canceled"); 505 dbus::ErrorResponse::FromMethodCall(
504 response_sender.Run(response); 506 method_call, bluetooth_agent::kErrorCanceled, "canceled")
507 .PassAs<dbus::Response>());
505 break; 508 break;
506 } 509 }
507 default: 510 default:
508 NOTREACHED() << "Unexpected status code from delegate: " << status; 511 NOTREACHED() << "Unexpected status code from delegate: " << status;
509 } 512 }
510 } 513 }
511 514
512 // Origin thread (i.e. the UI thread in production). 515 // Origin thread (i.e. the UI thread in production).
513 base::PlatformThreadId origin_thread_id_; 516 base::PlatformThreadId origin_thread_id_;
514 517
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 const dbus::ObjectPath& object_path, 564 const dbus::ObjectPath& object_path,
562 Delegate* delegate) { 565 Delegate* delegate) {
563 if (base::chromeos::IsRunningOnChromeOS()) { 566 if (base::chromeos::IsRunningOnChromeOS()) {
564 return new BluetoothAgentServiceProviderImpl(bus, object_path, delegate); 567 return new BluetoothAgentServiceProviderImpl(bus, object_path, delegate);
565 } else { 568 } else {
566 return new BluetoothAgentServiceProviderStubImpl(delegate); 569 return new BluetoothAgentServiceProviderStubImpl(delegate);
567 } 570 }
568 } 571 }
569 572
570 } // namespace chromeos 573 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/blocking_method_caller_unittest.cc ('k') | chromeos/dbus/ibus/ibus_engine_factory_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698