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

Unified Diff: chromeos/dbus/cras_audio_client.cc

Issue 23444057: Reduce chrome cras dbus call logs during device rebooting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename EnableLog Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/cras_audio_client.h ('k') | chromeos/dbus/cras_audio_client_stub_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/cras_audio_client.cc
diff --git a/chromeos/dbus/cras_audio_client.cc b/chromeos/dbus/cras_audio_client.cc
index 7a0b1c37f0b73e2e138f9efc28ab00f7084d9d47..f9023d64ce381a319544564644db5e1bc6c7f0c8 100644
--- a/chromeos/dbus/cras_audio_client.cc
+++ b/chromeos/dbus/cras_audio_client.cc
@@ -16,6 +16,10 @@
namespace chromeos {
+// Error name if cras dbus call fails with empty ErrorResponse.
+const char kNoResponseError[] =
+ "org.chromium.cras.Error.NoResponse";
+
// The CrasAudioClient implementation used in production.
class CrasAudioClientImpl : public CrasAudioClient {
public:
@@ -47,14 +51,17 @@ class CrasAudioClientImpl : public CrasAudioClient {
weak_ptr_factory_.GetWeakPtr(), callback));
}
- virtual void GetNodes(const GetNodesCallback& callback) OVERRIDE {
+ virtual void GetNodes(const GetNodesCallback& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(cras::kCrasControlInterface,
cras::kGetNodes);
- cras_proxy_->CallMethod(
+ cras_proxy_->CallMethodWithErrorCallback(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&CrasAudioClientImpl::OnGetNodes,
- weak_ptr_factory_.GetWeakPtr(), callback));
+ weak_ptr_factory_.GetWeakPtr(), callback),
+ base::Bind(&CrasAudioClientImpl::OnError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
virtual void SetOutputNodeVolume(uint64 node_id, int32 volume) OVERRIDE {
@@ -293,14 +300,28 @@ class CrasAudioClientImpl : public CrasAudioClient {
}
}
- if (node_list.size() == 0) {
- success = false;
- LOG(ERROR) << "Error calling " << cras::kGetNodes;
- }
+ if (node_list.size() == 0)
+ return;
callback.Run(node_list, success);
}
+ void OnError(const ErrorCallback& error_callback,
+ dbus::ErrorResponse* response) {
+ // Error response has optional error message argument.
+ std::string error_name;
+ std::string error_message;
+ if (response) {
+ dbus::MessageReader reader(response);
+ error_name = response->GetErrorName();
+ reader.PopString(&error_message);
+ } else {
+ error_name = kNoResponseError;
+ error_message = "";
+ }
+ error_callback.Run(error_name, error_message);
+ }
+
bool GetAudioNode(dbus::Response* response,
dbus::MessageReader* array_reader,
AudioNode *node) {
« no previous file with comments | « chromeos/dbus/cras_audio_client.h ('k') | chromeos/dbus/cras_audio_client_stub_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698