Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: ppapi/cpp/dev/network_proxy_dev.cc

Issue 16819002: PPAPI: Introduce PPB_NetworkProxy_Dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/dev/network_proxy_dev.cc
diff --git a/ppapi/cpp/dev/network_proxy_dev.cc b/ppapi/cpp/dev/network_proxy_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..36a45ec91090dec4ffdcb21ff9a0aa69f047027c
--- /dev/null
+++ b/ppapi/cpp/dev/network_proxy_dev.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/network_proxy_dev.h"
+
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_NetworkProxy_Dev_0_1>() {
+ return PPB_NETWORKPROXY_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+// static
+bool NetworkProxy::IsAvailable() {
+ return has_interface<PPB_NetworkProxy_Dev_0_1>();
+}
+
+// static
+int32_t NetworkProxy::GetProxyForURL(
+ const InstanceHandle& instance,
+ const std::string& url,
+ const CompletionCallbackWithOutput<Var>& callback) {
+ if (!has_interface<PPB_NetworkProxy_Dev_0_1>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+
+ Var url_var(url);
+ // The Var will be null if the url is not valid UTF-8.
+ if (url_var.is_null())
yzshen1 2013/06/16 23:49:53 It seems unnecessary to check |url_var| here: the
dmichael (off chromium) 2013/06/17 21:48:28 Good point. I took your suggestion of using Var, s
+ return callback.MayForce(PP_ERROR_BADARGUMENT);
+
+ return get_interface<PPB_NetworkProxy_Dev_0_1>()->GetProxyForURL(
+ instance.pp_instance(), url_var.pp_var(),
+ callback.output(), callback.pp_completion_callback());
+}
+
+} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698