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

Unified Diff: chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.cc

Issue 1665453003: Add browser tests for FetchEvent.request.mode/credentials in the service worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated jochen's comment Created 4 years, 10 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: chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.cc
diff --git a/chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.cc b/chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ef656bf3ee492bd2f776fad4dd8705775fdf1bf
--- /dev/null
+++ b/chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 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 <string>
+
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/url_loader.h"
+#include "ppapi/cpp/url_request_info.h"
+#include "ppapi/cpp/url_response_info.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/utility/completion_callback_factory.h"
+
+class PnaclUrlLoaderInstance : public pp::Instance {
+ public:
+ explicit PnaclUrlLoaderInstance(PP_Instance instance)
+ : pp::Instance(instance), loader_(this), factory_(this) {}
+
+ void HandleMessage(const pp::Var& var_message) override {
+ if (var_message.is_string()) {
+ command_ = var_message.AsString();
+ pp::URLRequestInfo request(this);
+ request.SetMethod("GET");
+ if (command_.find("Other") != std::string::npos)
+ request.SetURL("https://www.example.com/echo");
+ else
+ request.SetURL("/echo");
+ if (command_.find("CORS") != std::string::npos)
+ request.SetAllowCrossOriginRequests(true);
+ if (command_.find("Credentials") != std::string::npos)
+ request.SetAllowCredentials(true);
+ loader_.Open(request,
+ factory_.NewCallback(&PnaclUrlLoaderInstance::OnOpen));
+ return;
+ }
+ }
+
+ private:
+ void OnOpen(int32_t result) { PostMessage(pp::Var("OnOpen" + command_)); }
+
+ pp::URLLoader loader_;
+ pp::CompletionCallbackFactory<PnaclUrlLoaderInstance> factory_;
+ std::string command_;
+};
+
+class PnaclUrlLoaderModule : public pp::Module {
+ public:
+ virtual pp::Instance* CreateInstance(PP_Instance instance) {
+ return new PnaclUrlLoaderInstance(instance);
+ }
+};
+
+namespace pp {
+
+__attribute__((visibility("default"))) Module* CreateModule() {
+ return new PnaclUrlLoaderModule();
+}
+
+} // namespace pp
« no previous file with comments | « chrome/test/data/nacl/nacl_test_data.gyp ('k') | chrome/test/data/nacl/pnacl_url_loader/pnacl_url_loader.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698