summaryrefslogtreecommitdiff
path: root/chromeos-dbus-bindings
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@chromium.org>2014-11-20 15:06:09 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-22 01:40:51 +0000
commitc95f06bd6f672f408c5f77948781392098f52a86 (patch)
treeaaef3982d93c4edc14dd04e7771de05e6dcf6be2 /chromeos-dbus-bindings
parent4f3c05eed11d5f1e279313bafb1d8d693774d35f (diff)
downloaddbus-binding-generator-c95f06bd6f672f408c5f77948781392098f52a86.tar.gz
chromeos-dbus-bindings: passing multiple input files on command line
When generating D-Bus proxies for objects under D-Bus Object Manager control, it is important to group all the proxies and tie them to a single instance of Object Manager proxy that knows about the subordinate interfaces and their properties. In order to do this, multiple source XML files will be grouped into one proxy header file, complete with all the proxy interfaces, signal handlers as well as a single Object Manager proxy class that manages all those proxies (this part will be done in a separate CL). In order to supply more than one source XML file to the generator executable, remove --input switch and let the files be passed directly. GYP files that import proxies from other projects will need to do so for more than one source target, so they can use a single GYP rule as was defined in generate-dbus-bindings.gypi. However, that rule is totally acceptable for generating adaptors, so, renamed the generate-dbus-bindings.gypi into generate-dbus-adaptors.gypi to be more specific and simplified it a bit. Also made generated object proxies to allow explicit releasing of the underlying dbus::ObjectProxy from the dbus::Bus. This is cannot be done in the constructor since dbus::Bus::RemoveObjectProxy is an asynchronous call and requires a message loop to be executed. For clients such as buffet_client that doesn't have a message loop, removing the proxy in the destructor causes a crash. For clients like Shill who need to keep the bus clean, they can call ReleaseObjectProxy() before destroying the proxy object. BUG=chromium:431737 TEST=FEATURES=test emerge-link chromeos-dbus-bindings lorgnette apmanager Change-Id: I6737c155c528f46d480d51aaf8420a1dad00f83e Reviewed-on: https://chromium-review.googlesource.com/231155 Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Diffstat (limited to 'chromeos-dbus-bindings')
-rw-r--r--chromeos-dbus-bindings/adaptor_generator.cc2
-rw-r--r--chromeos-dbus-bindings/generate_chromeos_dbus_bindings.cc31
-rw-r--r--chromeos-dbus-bindings/header_generator.cc5
-rw-r--r--chromeos-dbus-bindings/header_generator.h3
-rw-r--r--chromeos-dbus-bindings/proxy_generator.cc192
-rw-r--r--chromeos-dbus-bindings/proxy_generator.h18
-rw-r--r--chromeos-dbus-bindings/proxy_generator_unittest.cc59
7 files changed, 200 insertions, 110 deletions
diff --git a/chromeos-dbus-bindings/adaptor_generator.cc b/chromeos-dbus-bindings/adaptor_generator.cc
index e8b5fe1..d1cb882 100644
--- a/chromeos-dbus-bindings/adaptor_generator.cc
+++ b/chromeos-dbus-bindings/adaptor_generator.cc
@@ -32,7 +32,7 @@ bool AdaptorGenerator::GenerateAdaptors(
for (const auto& interface : interfaces) {
text.AddLine(StringPrintf("// - %s", interface.name.c_str()));
}
- string header_guard = GenerateHeaderGuard(output_file, "");
+ string header_guard = GenerateHeaderGuard(output_file);
text.AddLine(StringPrintf("#ifndef %s", header_guard.c_str()));
text.AddLine(StringPrintf("#define %s", header_guard.c_str()));
text.AddLine("#include <memory>");
diff --git a/chromeos-dbus-bindings/generate_chromeos_dbus_bindings.cc b/chromeos-dbus-bindings/generate_chromeos_dbus_bindings.cc
index 842a64f..37d5838 100644
--- a/chromeos-dbus-bindings/generate_chromeos_dbus_bindings.cc
+++ b/chromeos-dbus-bindings/generate_chromeos_dbus_bindings.cc
@@ -7,6 +7,7 @@
#include <base/command_line.h>
#include <base/files/file_path.h>
#include <base/logging.h>
+#include <base/strings/string_util.h>
#include <chromeos/syslog_logging.h>
#include "chromeos-dbus-bindings/adaptor_generator.h"
@@ -21,14 +22,13 @@ using chromeos_dbus_bindings::ProxyGenerator;
namespace switches {
static const char kHelp[] = "help";
-static const char kInput[] = "input";
static const char kMethodNames[] = "method-names";
static const char kAdaptor[] = "adaptor";
static const char kProxy[] = "proxy";
static const char kHelpMessage[] = "\n"
+ "generate-chromeos-dbus-bindings itf1.xml [itf2.xml...] [switches]\n"
+ " itf1.xml, ... = the input interface file(s) [mandatory].\n"
"Available Switches: \n"
- " --input=<interface>\n"
- " The input XML interface file (mandatory).\n"
" --method-names=<method name header filename>\n"
" The output header file with string constants for each method name.\n"
" --adaptor=<adaptor header filename>\n"
@@ -51,18 +51,19 @@ int main(int argc, char** argv) {
return 0;
}
- if (!cl->HasSwitch(switches::kInput)) {
- LOG(ERROR) << switches::kInput << " switch is mandatory.";
+ auto input_files = cl->GetArgs();
+ if (input_files.empty()) {
+ LOG(ERROR) << "At least one file must be specified.";
LOG(ERROR) << switches::kHelpMessage;
return 1;
}
- std::string input = cl->GetSwitchValueASCII(switches::kInput);
-
chromeos_dbus_bindings::XmlInterfaceParser parser;
- if (!parser.ParseXmlInterfaceFile(base::FilePath(input))) {
- LOG(ERROR) << "Failed to parse interface file.";
- return 1;
+ for (const auto& input : input_files) {
+ if (!parser.ParseXmlInterfaceFile(base::FilePath(input))) {
+ LOG(ERROR) << "Failed to parse interface file.";
+ return 1;
+ }
}
if (cl->HasSwitch(switches::kMethodNames)) {
@@ -79,6 +80,9 @@ int main(int argc, char** argv) {
if (cl->HasSwitch(switches::kAdaptor)) {
std::string adaptor_file = cl->GetSwitchValueASCII(switches::kAdaptor);
+ // GYP sometimes enclosed the target file name in extra set of quotes like:
+ // generate-chromeos-dbus-buindings in.xml "--adaptor=\"out.h\""
+ base::TrimString(adaptor_file, "\"'", &adaptor_file);
VLOG(1) << "Outputting adaptor to " << adaptor_file;
if (!AdaptorGenerator::GenerateAdaptors(parser.interfaces(),
base::FilePath(adaptor_file))) {
@@ -89,9 +93,12 @@ int main(int argc, char** argv) {
if (cl->HasSwitch(switches::kProxy)) {
std::string proxy_file = cl->GetSwitchValueASCII(switches::kProxy);
+ // GYP sometimes enclosed the target file name in extra set of quotes like:
+ // generate-chromeos-dbus-buindings in.xml "--proxy=\"out.h\""
+ base::TrimString(proxy_file, "\"'", &proxy_file);
VLOG(1) << "Outputting proxy to " << proxy_file;
- if (!ProxyGenerator::GenerateProxy(parser.interfaces(),
- base::FilePath(proxy_file))) {
+ if (!ProxyGenerator::GenerateProxies(parser.interfaces(),
+ base::FilePath(proxy_file))) {
LOG(ERROR) << "Failed to output proxy.";
return 1;
}
diff --git a/chromeos-dbus-bindings/header_generator.cc b/chromeos-dbus-bindings/header_generator.cc
index f947650..41d7e1b 100644
--- a/chromeos-dbus-bindings/header_generator.cc
+++ b/chromeos-dbus-bindings/header_generator.cc
@@ -22,9 +22,8 @@ namespace chromeos_dbus_bindings {
// static
string HeaderGenerator::GenerateHeaderGuard(
- const base::FilePath& output_file, const string& interface_name) {
- string guard = base::StringPrintf("____chromeos_dbus_binding___%s__%s",
- interface_name.c_str(),
+ const base::FilePath& output_file) {
+ string guard = base::StringPrintf("____chromeos_dbus_binding__%s",
output_file.value().c_str());
for (auto& c : guard) {
if (IsAsciiAlpha(c)) {
diff --git a/chromeos-dbus-bindings/header_generator.h b/chromeos-dbus-bindings/header_generator.h
index b4f521d..e4896ca 100644
--- a/chromeos-dbus-bindings/header_generator.h
+++ b/chromeos-dbus-bindings/header_generator.h
@@ -24,8 +24,7 @@ class IndentedText;
class HeaderGenerator {
protected:
// Create a unique header guard string to protect multiple includes of header.
- static std::string GenerateHeaderGuard(const base::FilePath& output_file,
- const std::string& interface_name);
+ static std::string GenerateHeaderGuard(const base::FilePath& output_file);
// Returns a vector of nesting namespaces.
static bool GetNamespacesAndClassName(const std::string& interface_name,
diff --git a/chromeos-dbus-bindings/proxy_generator.cc b/chromeos-dbus-bindings/proxy_generator.cc
index 44a1c56..ca6efd7 100644
--- a/chromeos-dbus-bindings/proxy_generator.cc
+++ b/chromeos-dbus-bindings/proxy_generator.cc
@@ -18,23 +18,16 @@ using std::vector;
namespace chromeos_dbus_bindings {
// static
-bool ProxyGenerator::GenerateProxy(
+bool ProxyGenerator::GenerateProxies(
const std::vector<Interface>& interfaces,
const base::FilePath& output_file) {
IndentedText text;
- CHECK(!interfaces.empty()) << "At least one interface must be provided";
- vector<string> namespaces;
- string proxy_name;
- CHECK(GetNamespacesAndClassName(interfaces.front().name,
- &namespaces,
- &proxy_name));
- proxy_name += "Proxy";
text.AddLine("// Automatic generation of D-Bus interfaces:");
for (const auto& interface : interfaces) {
text.AddLine(StringPrintf("// - %s", interface.name.c_str()));
}
- string header_guard = GenerateHeaderGuard(output_file, proxy_name);
+ string header_guard = GenerateHeaderGuard(output_file);
text.AddLine(StringPrintf("#ifndef %s", header_guard.c_str()));
text.AddLine(StringPrintf("#define %s", header_guard.c_str()));
text.AddLine("#include <string>");
@@ -56,62 +49,78 @@ bool ProxyGenerator::GenerateProxy(
text.AddLine("#include <dbus/object_proxy.h>");
text.AddBlankLine();
+ for (const auto& interface : interfaces) {
+ GenerateInterfaceProxy(interface, &text);
+ }
+
+ text.AddLine(StringPrintf("#endif // %s", header_guard.c_str()));
+ return WriteTextToFile(output_file, text);
+}
+
+// static
+void ProxyGenerator::GenerateInterfaceProxy(const Interface& interface,
+ IndentedText* text) {
+ vector<string> namespaces;
+ string itf_name;
+ CHECK(GetNamespacesAndClassName(interface.name,
+ &namespaces,
+ &itf_name));
+ string proxy_name = itf_name + "Proxy";
+
for (const auto& space : namespaces) {
- text.AddLine(StringPrintf("namespace %s {", space.c_str()));
+ text->AddLine(StringPrintf("namespace %s {", space.c_str()));
}
- text.AddBlankLine();
+ text->AddBlankLine();
- text.AddLine(StringPrintf("class %s final {", proxy_name.c_str()));
- text.AddLineWithOffset("public:", kScopeOffset);
- text.PushOffset(kBlockOffset);
- AddSignalReceiver(interfaces, &text);
- AddConstructor(interfaces, proxy_name, &text);
- AddDestructor(proxy_name, &text);
- AddSignalConnectedCallback(&text);
- for (const auto& interface : interfaces) {
- for (const auto& method : interface.methods) {
- AddMethodProxy(method, interface.name, &text);
- }
+ text->AddLine(StringPrintf("// Interface proxy for %s.",
+ GetFullClassName(namespaces, itf_name).c_str()));
+ text->AddLine(StringPrintf("class %s final {", proxy_name.c_str()));
+ text->AddLineWithOffset("public:", kScopeOffset);
+ text->PushOffset(kBlockOffset);
+ AddSignalReceiver(interface, text);
+ AddConstructor(interface, proxy_name, text);
+ AddDestructor(proxy_name, text);
+ AddReleaseObjectProxy(text);
+ if (!interface.signals.empty())
+ AddSignalConnectedCallback(text);
+ for (const auto& method : interface.methods) {
+ AddMethodProxy(method, interface.name, text);
}
- text.PopOffset();
- text.AddBlankLine();
- text.AddLineWithOffset("private:", kScopeOffset);
+ text->PopOffset();
+ text->AddLineWithOffset("private:", kScopeOffset);
- text.PushOffset(kBlockOffset);
- text.AddLine("scoped_refptr<dbus::Bus> bus_;");
- text.AddLine("std::string service_name_;");
- text.AddLine("dbus::ObjectPath object_path_;");
- text.AddLine("dbus::ObjectProxy* dbus_object_proxy_;");
- text.AddBlankLine();
+ text->PushOffset(kBlockOffset);
+ text->AddLine("scoped_refptr<dbus::Bus> bus_;");
+ text->AddLine("std::string service_name_;");
+ text->AddLine("dbus::ObjectPath object_path_;");
+ text->AddLine("dbus::ObjectProxy* dbus_object_proxy_;");
+ text->AddBlankLine();
- text.AddLine(StringPrintf(
+ text->AddLine(StringPrintf(
"DISALLOW_COPY_AND_ASSIGN(%s);", proxy_name.c_str()));
- text.PopOffset();
- text.AddLine("};");
+ text->PopOffset();
+ text->AddLine("};");
- text.AddBlankLine();
+ text->AddBlankLine();
for (auto it = namespaces.rbegin(); it != namespaces.rend(); ++it) {
- text.AddLine(StringPrintf("} // namespace %s", it->c_str()));
+ text->AddLine(StringPrintf("} // namespace %s", it->c_str()));
}
- text.AddLine(StringPrintf("#endif // %s", header_guard.c_str()));
- return WriteTextToFile(output_file, text);
+ text->AddBlankLine();
}
// static
-void ProxyGenerator::AddConstructor(const vector<Interface>& interfaces,
+void ProxyGenerator::AddConstructor(const Interface& interface,
const string& class_name,
IndentedText* text) {
IndentedText block;
- block.AddBlankLine();
block.AddLine(StringPrintf("%s(", class_name.c_str()));
block.PushOffset(kLineContinuationOffset);
block.AddLine("const scoped_refptr<dbus::Bus>& bus,");
block.AddLine("const std::string& service_name,");
- block.AddLine("const std::string& object_path,");
- block.AddLine("SignalReceiver* signal_receiver)");
+ block.AddLine("const std::string& object_path)");
block.AddLine(": bus_(bus),");
block.PushOffset(kBlockOffset);
block.AddLine("service_name_(service_name),");
@@ -122,8 +131,19 @@ void ProxyGenerator::AddConstructor(const vector<Interface>& interfaces,
kLineContinuationOffset);
block.PopOffset();
block.PopOffset();
- block.PushOffset(kBlockOffset);
- for (const auto& interface : interfaces) {
+ block.AddLine("}");
+ if (!interface.signals.empty()) {
+ block.AddBlankLine();
+ block.AddLine(StringPrintf("%s(", class_name.c_str()));
+ block.PushOffset(kLineContinuationOffset);
+ block.AddLine("const scoped_refptr<dbus::Bus>& bus,");
+ block.AddLine("const std::string& service_name,");
+ block.AddLine("const std::string& object_path,");
+ block.AddLine("SignalReceiver* signal_receiver)");
+ block.AddLine(StringPrintf(": %s(bus, service_name, object_path) {",
+ class_name.c_str()));
+ block.PopOffset();
+ block.PushOffset(kBlockOffset);
for (const auto& signal : interface.signals) {
block.AddLine("chromeos::dbus_utils::ConnectToSignal(");
block.PushOffset(kLineContinuationOffset);
@@ -145,10 +165,10 @@ void ProxyGenerator::AddConstructor(const vector<Interface>& interfaces,
block.PopOffset();
block.PopOffset();
}
+ block.PopOffset();
+ block.AddLine("}");
}
- block.PopOffset();
- block.AddLine("}");
-
+ block.AddBlankLine();
text->AddBlock(block);
}
@@ -156,21 +176,28 @@ void ProxyGenerator::AddConstructor(const vector<Interface>& interfaces,
void ProxyGenerator::AddDestructor(const string& class_name,
IndentedText* text) {
IndentedText block;
- block.AddBlankLine();
block.AddLine(StringPrintf("~%s() {", class_name.c_str()));
+ block.AddLine("}");
+ block.AddBlankLine();
+ text->AddBlock(block);
+}
+
+// static
+void ProxyGenerator::AddReleaseObjectProxy(IndentedText* text) {
+ IndentedText block;
+ block.AddLine("void ReleaseObjectProxy(const base::Closure& callback) {");
block.PushOffset(kBlockOffset);
- block.AddLine("dbus_object_proxy_->Detach();");
block.AddLine(
- "bus_->RemoveObjectProxy(service_name_, object_path_, base::Closure());");
+ "bus_->RemoveObjectProxy(service_name_, object_path_, callback);");
block.PopOffset();
block.AddLine("}");
+ block.AddBlankLine();
text->AddBlock(block);
}
// static
void ProxyGenerator::AddSignalConnectedCallback(IndentedText* text) {
IndentedText block;
- block.AddBlankLine();
block.AddLine("void OnDBusSignalConnected(");
block.PushOffset(kLineContinuationOffset);
block.AddLine("const std::string& interface,");
@@ -190,51 +217,54 @@ void ProxyGenerator::AddSignalConnectedCallback(IndentedText* text) {
block.AddLine("}");
block.PopOffset();
block.AddLine("}");
+ block.AddBlankLine();
text->AddBlock(block);
}
// static
-void ProxyGenerator::AddSignalReceiver(const vector<Interface>& interfaces,
+void ProxyGenerator::AddSignalReceiver(const Interface& interface,
IndentedText* text) {
+ if (interface.signals.empty())
+ return;
+
IndentedText block;
block.AddLine("class SignalReceiver {");
block.AddLineWithOffset("public:", kScopeOffset);
block.PushOffset(kBlockOffset);
DbusSignature signature;
- for (const auto& interface : interfaces) {
- for (const auto& signal : interface.signals) {
- block.AddComments(signal.doc_string_);
- string signal_begin = StringPrintf(
- "virtual void %s(", GetHandlerNameForSignal(signal.name).c_str());
- string signal_end = ") {}";
-
- if (signal.arguments.empty()) {
- block.AddLine(signal_begin + signal_end);
- continue;
+ for (const auto& signal : interface.signals) {
+ block.AddComments(signal.doc_string_);
+ string signal_begin = StringPrintf(
+ "virtual void %s(", GetHandlerNameForSignal(signal.name).c_str());
+ string signal_end = ") {}";
+
+ if (signal.arguments.empty()) {
+ block.AddLine(signal_begin + signal_end);
+ continue;
+ }
+ block.AddLine(signal_begin);
+ block.PushOffset(kLineContinuationOffset);
+ string last_argument;
+ vector<string> argument_types;
+ for (const auto& argument : signal.arguments) {
+ if (!last_argument.empty()) {
+ block.AddLine(StringPrintf("%s,", last_argument.c_str()));
}
- block.AddLine(signal_begin);
- block.PushOffset(kLineContinuationOffset);
- string last_argument;
- vector<string> argument_types;
- for (const auto& argument : signal.arguments) {
- if (!last_argument.empty()) {
- block.AddLine(StringPrintf("%s,", last_argument.c_str()));
- }
- CHECK(signature.Parse(argument.type, &last_argument));
- if (!IsIntegralType(last_argument)) {
- last_argument = StringPrintf("const %s&", last_argument.c_str());
- }
- if (!argument.name.empty()) {
- last_argument += ' ';
- last_argument += argument.name;
- }
+ CHECK(signature.Parse(argument.type, &last_argument));
+ if (!IsIntegralType(last_argument)) {
+ last_argument = StringPrintf("const %s&", last_argument.c_str());
+ }
+ if (!argument.name.empty()) {
+ last_argument += ' ';
+ last_argument += argument.name;
}
- block.AddLine(last_argument + signal_end);
- block.PopOffset();
}
+ block.AddLine(last_argument + signal_end);
+ block.PopOffset();
}
block.PopOffset();
block.AddLine("};");
+ block.AddBlankLine();
text->AddBlock(block);
}
@@ -245,7 +275,6 @@ void ProxyGenerator::AddMethodProxy(const Interface::Method& method,
IndentedText* text) {
IndentedText block;
DbusSignature signature;
- block.AddBlankLine();
block.AddComments(method.doc_string_);
block.AddLine(StringPrintf("bool %s(", method.name.c_str()));
block.PushOffset(kLineContinuationOffset);
@@ -295,6 +324,7 @@ void ProxyGenerator::AddMethodProxy(const Interface::Method& method,
block.PopOffset();
block.PopOffset();
block.AddLine("}");
+ block.AddBlankLine();
text->AddBlock(block);
}
diff --git a/chromeos-dbus-bindings/proxy_generator.h b/chromeos-dbus-bindings/proxy_generator.h
index b8f7e7b..591648d 100644
--- a/chromeos-dbus-bindings/proxy_generator.h
+++ b/chromeos-dbus-bindings/proxy_generator.h
@@ -27,24 +27,32 @@ struct Interface;
class ProxyGenerator : public HeaderGenerator {
public:
- static bool GenerateProxy(const std::vector<Interface>& interfaces,
- const base::FilePath& output_file);
+ static bool GenerateProxies(const std::vector<Interface>& interfaces,
+ const base::FilePath& output_file);
private:
friend class ProxyGeneratorTest;
+ // Generates one interface proxy.
+ static void GenerateInterfaceProxy(const Interface& interface,
+ IndentedText* text);
+
// Generates the constructor and destructor for the proxy.
- static void AddConstructor(const std::vector<Interface>& interfaces,
+ static void AddConstructor(const Interface& interface,
const std::string& class_name,
IndentedText* text);
static void AddDestructor(const std::string& class_name,
IndentedText* text);
// Generates a callback for signal receiver registration completion.
- static void AddSignalConnectedCallback(IndentedText *text);
+ static void AddSignalConnectedCallback(IndentedText* text);
+
+ // Generates ReleaseObjectProxy() method to release ownership
+ // of the object proxy.
+ static void AddReleaseObjectProxy(IndentedText* text);
// Generates the method signatures for signal receivers.
- static void AddSignalReceiver(const std::vector<Interface>& interfaces,
+ static void AddSignalReceiver(const Interface& interface,
IndentedText* text);
// Generates a native C++ method which calls a D-Bus method on the proxy.
diff --git a/chromeos-dbus-bindings/proxy_generator_unittest.cc b/chromeos-dbus-bindings/proxy_generator_unittest.cc
index 6c5e1a6..0b35fc8 100644
--- a/chromeos-dbus-bindings/proxy_generator_unittest.cc
+++ b/chromeos-dbus-bindings/proxy_generator_unittest.cc
@@ -66,6 +66,7 @@ const char kExpectedContent[] = R"literal_string(
namespace org {
namespace chromium {
+// Interface proxy for org::chromium::TestInterface.
class TestInterfaceProxy final {
public:
class SignalReceiver {
@@ -79,13 +80,20 @@ class TestInterfaceProxy final {
TestInterfaceProxy(
const scoped_refptr<dbus::Bus>& bus,
const std::string& service_name,
- const std::string& object_path,
- SignalReceiver* signal_receiver)
+ const std::string& object_path)
: bus_(bus),
service_name_(service_name),
object_path_(object_path),
dbus_object_proxy_(
bus_->GetObjectProxy(service_name_, object_path_)) {
+ }
+
+ TestInterfaceProxy(
+ const scoped_refptr<dbus::Bus>& bus,
+ const std::string& service_name,
+ const std::string& object_path,
+ SignalReceiver* signal_receiver)
+ : TestInterfaceProxy(bus, service_name, object_path) {
chromeos::dbus_utils::ConnectToSignal(
dbus_object_proxy_,
"org.chromium.TestInterface",
@@ -109,8 +117,10 @@ class TestInterfaceProxy final {
}
~TestInterfaceProxy() {
- dbus_object_proxy_->Detach();
- bus_->RemoveObjectProxy(service_name_, object_path_, base::Closure());
+ }
+
+ void ReleaseObjectProxy(const base::Closure& callback) {
+ bus_->RemoveObjectProxy(service_name_, object_path_, callback);
}
void OnDBusSignalConnected(
@@ -179,6 +189,42 @@ class TestInterfaceProxy final {
response.get(), error);
}
+ private:
+ scoped_refptr<dbus::Bus> bus_;
+ std::string service_name_;
+ dbus::ObjectPath object_path_;
+ dbus::ObjectProxy* dbus_object_proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestInterfaceProxy);
+};
+
+} // namespace chromium
+} // namespace org
+
+namespace org {
+namespace chromium {
+
+// Interface proxy for org::chromium::TestInterface2.
+class TestInterface2Proxy final {
+ public:
+ TestInterface2Proxy(
+ const scoped_refptr<dbus::Bus>& bus,
+ const std::string& service_name,
+ const std::string& object_path)
+ : bus_(bus),
+ service_name_(service_name),
+ object_path_(object_path),
+ dbus_object_proxy_(
+ bus_->GetObjectProxy(service_name_, object_path_)) {
+ }
+
+ ~TestInterface2Proxy() {
+ }
+
+ void ReleaseObjectProxy(const base::Closure& callback) {
+ bus_->RemoveObjectProxy(service_name_, object_path_, callback);
+ }
+
bool GetPersonInfo(
std::string* out_name,
int32_t* out_age,
@@ -198,11 +244,12 @@ class TestInterfaceProxy final {
dbus::ObjectPath object_path_;
dbus::ObjectProxy* dbus_object_proxy_;
- DISALLOW_COPY_AND_ASSIGN(TestInterfaceProxy);
+ DISALLOW_COPY_AND_ASSIGN(TestInterface2Proxy);
};
} // namespace chromium
} // namespace org
+
)literal_string";
} // namespace
@@ -260,7 +307,7 @@ TEST_F(ProxyGeneratorTest, GenerateAdaptors) {
{kMethod5ArgumentName2, kMethod5Argument2}});
vector<Interface> interfaces{interface, interface2};
base::FilePath output_path = temp_dir_.path().Append("output.h");
- EXPECT_TRUE(ProxyGenerator::GenerateProxy(interfaces, output_path));
+ EXPECT_TRUE(ProxyGenerator::GenerateProxies(interfaces, output_path));
string contents;
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for