chore: remove native_mate (Part 10) (#20696)

* refactor: remove direct uses of event_emitter_deprecated.h

* refactor: remove event_emitter_deprecated.h in api::App

* refactor: use std::move to save a copy

* fix: windows and linux builds
This commit is contained in:
Cheng Zhao 2019-10-24 14:47:58 +09:00 committed by GitHub
parent 77414813b4
commit be955a9721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 223 additions and 199 deletions

View file

@ -5,8 +5,11 @@
#ifndef SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_
#define SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/optional.h"
#include "gin/arguments.h"
#include "shell/common/gin_helper/arguments.h"
#include "shell/common/gin_helper/destroyable.h"
@ -90,6 +93,20 @@ bool GetNextArgument(gin::Arguments* args,
}
}
// Support base::Optional as output, which would be empty and do not throw error
// when convertion to T fails.
template <typename T>
bool GetNextArgument(gin::Arguments* args,
int create_flags,
bool is_first,
base::Optional<T>* result) {
T converted;
// Use gin::Arguments::GetNext which always advances |next| counter.
if (args->GetNext(&converted))
result->emplace(std::move(converted));
return true;
}
// For advanced use cases, we allow callers to request the unparsed Arguments
// object and poke around in it directly.
inline bool GetNextArgument(gin::Arguments* args,