blob: 13fe8146d61cac5e46555462d349eaae5a46f921 [file] [log] [blame]
Darin Petkova9b1fed2012-02-29 11:49:05 +01001// Copyright (c) 2012 The Chromium OS 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 SHILL_RPC_TASK_
6#define SHILL_RPC_TASK_
7
8#include <map>
9#include <string>
10
11#include <base/basictypes.h>
12#include <base/memory/scoped_ptr.h>
13
14namespace shill {
15
16class ControlInterface;
17class RPCTaskAdaptorInterface;
18
19class RPCTaskDelegate {
20 public:
21 virtual ~RPCTaskDelegate() {}
22
23 virtual void Notify(const std::string &reason,
24 const std::map<std::string, std::string> &dict) = 0;
25};
26
27// RPC tasks are currently used by VPN drivers for communication with external
28// VPN processes. The RPC task should be owned by a single owner -- its
29// RPCTaskDelegate -- so no need to be reference counted.
30class RPCTask {
31 public:
32 // A constructor for the RPCTask object.
33 RPCTask(ControlInterface *control_interface, RPCTaskDelegate *delegate);
34 virtual ~RPCTask();
35
36 virtual void Notify(const std::string &reason,
37 const std::map<std::string, std::string> &dict);
38
39 // Returns a string that is guaranteed to uniquely identify this RPCTask
40 // instance.
41 const std::string &UniqueName() const { return unique_name_; }
42
43 std::string GetRpcIdentifier() const;
44 std::string GetRpcInterfaceIdentifier() const;
45 std::string GetRpcConnectionIdentifier() const;
46
47 private:
48 RPCTaskDelegate *delegate_;
49 static unsigned int serial_number_;
50 std::string unique_name_; // MUST be unique amongst RPC task instances
51 scoped_ptr<RPCTaskAdaptorInterface> adaptor_;
52
53 DISALLOW_COPY_AND_ASSIGN(RPCTask);
54};
55
56} // namespace shill
57
58#endif // SHILL_RPC_TASK_