Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / network / network_handler_callbacks.h
blob4bdd687c1e39e81048ac725971c76ade5b1f6ed2
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.
5 #ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_
6 #define CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/dbus_method_call_status.h"
16 namespace base {
17 class DictionaryValue;
20 namespace chromeos {
21 namespace network_handler {
23 CHROMEOS_EXPORT extern const char kDBusFailedError[];
24 CHROMEOS_EXPORT extern const char kDBusFailedErrorMessage[];
25 CHROMEOS_EXPORT extern const char kErrorName[];
26 CHROMEOS_EXPORT extern const char kErrorDetail[];
27 CHROMEOS_EXPORT extern const char kDbusErrorName[];
28 CHROMEOS_EXPORT extern const char kDbusErrorMessage[];
30 // An error callback used by both the configuration handler and the state
31 // handler to receive error results from the API.
32 typedef base::Callback<
33 void(const std::string& error_name,
34 scoped_ptr<base::DictionaryValue> error_data)> ErrorCallback;
36 typedef base::Callback<
37 void(const std::string& service_path,
38 const base::DictionaryValue& dictionary)> DictionaryResultCallback;
40 typedef base::Callback<
41 void(const std::string& service_path)> StringResultCallback;
43 // Create a DictionaryValue for passing to ErrorCallback.
44 CHROMEOS_EXPORT base::DictionaryValue* CreateErrorData(
45 const std::string& path,
46 const std::string& error_name,
47 const std::string& error_detail);
49 // If not NULL, runs |error_callback| with an ErrorData dictionary created from
50 // the other arguments.
51 CHROMEOS_EXPORT void RunErrorCallback(const ErrorCallback& error_callback,
52 const std::string& path,
53 const std::string& error_name,
54 const std::string& error_detail);
56 CHROMEOS_EXPORT base::DictionaryValue* CreateDBusErrorData(
57 const std::string& path,
58 const std::string& error_name,
59 const std::string& error_detail,
60 const std::string& dbus_error_name,
61 const std::string& dbus_error_message);
63 // Callback for Shill errors.
64 // |error_name| is the error name passed to |error_callback|.
65 // |path| is the associated object path or blank if not relevant.
66 // |dbus_error_name| and |dbus_error_message| are provided by the DBus handler.
67 // Logs an error and calls |error_callback| if not null.
68 CHROMEOS_EXPORT void ShillErrorCallbackFunction(
69 const std::string& error_name,
70 const std::string& path,
71 const ErrorCallback& error_callback,
72 const std::string& dbus_error_name,
73 const std::string& dbus_error_message);
75 // Callback for property getters used by NetworkConfigurationHandler
76 // (for Network Services) and by NetworkDeviceHandler. Used to translate
77 // the DBus Dictionary callback into one that calls the error callback
78 // if |call_status| != DBUS_METHOD_CALL_SUCCESS.
79 CHROMEOS_EXPORT void GetPropertiesCallback(
80 const DictionaryResultCallback& callback,
81 const ErrorCallback& error_callback,
82 const std::string& path,
83 DBusMethodCallStatus call_status,
84 const base::DictionaryValue& value);
86 } // namespace network_handler
87 } // namespace chromeos
89 #endif // CHROMEOS_NETWORK_NETWORK_HANDLER_CALLBACKS_H_