network_handler_callbacks.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_
6#define CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/callback.h"
12#include "chromeos/chromeos_export.h"
13
14namespace base {
15class DictionaryValue;
16}
17
18namespace chromeos {
19namespace network_handler {
20
21// An error callback used by both the configuration handler and the state
22// handler to receive error results from the API.
23typedef base::Callback<
24  void(const std::string& error_name,
25       scoped_ptr<base::DictionaryValue> error_data)> ErrorCallback;
26
27typedef base::Callback<
28  void(const std::string& service_path,
29       const base::DictionaryValue& dictionary)> DictionaryResultCallback;
30
31typedef base::Callback<
32  void(const std::string& service_path)> StringResultCallback;
33
34// Create a DictionaryValue for passing to ErrorCallback
35CHROMEOS_EXPORT base::DictionaryValue* CreateErrorData(
36    const std::string& service_path,
37    const std::string& error_name,
38    const std::string& error_message);
39
40// Callback for Shill errors. |path| may be blank if not relevant.
41// Logs an error and calls |error_callback| if not null.
42void ShillErrorCallbackFunction(const std::string& path,
43                                const ErrorCallback& error_callback,
44                                const std::string& error_name,
45                                const std::string& error_message);
46
47}  // namespace network_handler
48}  // namespace chromeos
49
50#endif  // CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_
51