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

Unified Diff: native_client_sdk/src/examples/api/url_loader/url_loader.cc

Issue 14607005: [NaCl SDK] Cleanup examples. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 7 years, 7 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: native_client_sdk/src/examples/api/url_loader/url_loader.cc
diff --git a/native_client_sdk/src/examples/api/url_loader/geturl.cc b/native_client_sdk/src/examples/api/url_loader/url_loader.cc
similarity index 57%
rename from native_client_sdk/src/examples/api/url_loader/geturl.cc
rename to native_client_sdk/src/examples/api/url_loader/url_loader.cc
index db7abe20c89b623ff64e0173341e7e3435cd1eda..d000a93cd14e9f83aaa34f115974759712665c29 100644
--- a/native_client_sdk/src/examples/api/url_loader/geturl.cc
+++ b/native_client_sdk/src/examples/api/url_loader/url_loader.cc
@@ -7,11 +7,11 @@
#include <cstdio>
#include <string>
#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/var.h"
-#include "geturl_handler.h"
+#include "url_loader_handler.h"
// These are the method names as JavaScript sees them.
namespace {
@@ -20,20 +20,14 @@ static const char kMessageArgumentSeparator = ':';
// Exception strings. These are passed back to the browser when errors
// happen during property accesses or method calls.
-const char* const kExceptionStartFailed = "GetURLHandler::Start() failed";
+const char* const kExceptionStartFailed = "URLLoaderHandler::Start() failed";
const char* const kExceptionURLNotAString = "URL is not a string";
} // namespace
-// The Instance class. One of these exists for each instance of your NaCl
-// module on the web page. The browser will ask the Module object to create
-// a new Instance for each occurrence of the <embed> tag that has these
-// attributes:
-// type="application/x-nacl"
-// src="geturl.nmf"
-class GetURLInstance : public pp::Instance {
+class URLLoaderInstance : public pp::Instance {
public:
- explicit GetURLInstance(PP_Instance instance) : pp::Instance(instance) {}
- virtual ~GetURLInstance() {}
+ explicit URLLoaderInstance(PP_Instance instance) : pp::Instance(instance) {}
+ virtual ~URLLoaderInstance() {}
// Called by the browser to handle the postMessage() call in Javascript.
// The message in this case is expected to contain the string 'getUrl'
@@ -44,7 +38,7 @@ class GetURLInstance : public pp::Instance {
virtual void HandleMessage(const pp::Var& var_message);
};
-void GetURLInstance::HandleMessage(const pp::Var& var_message) {
+void URLLoaderInstance::HandleMessage(const pp::Var& var_message) {
if (!var_message.is_string()) {
return;
}
@@ -54,11 +48,11 @@ void GetURLInstance::HandleMessage(const pp::Var& var_message) {
size_t sep_pos = message.find_first_of(kMessageArgumentSeparator);
if (sep_pos != std::string::npos) {
std::string url = message.substr(sep_pos + 1);
- printf("GetURLInstance::HandleMessage('%s', '%s')\n",
+ printf("URLLoaderInstance::HandleMessage('%s', '%s')\n",
message.c_str(),
url.c_str());
fflush(stdout);
- GetURLHandler* handler = GetURLHandler::Create(this, url);
+ URLLoaderHandler* handler = URLLoaderHandler::Create(this, url);
if (handler != NULL) {
// Starts asynchronous download. When download is finished or when an
// error occurs, |handler| posts the results back to the browser
@@ -69,25 +63,17 @@ void GetURLInstance::HandleMessage(const pp::Var& var_message) {
}
}
-// The Module class. The browser calls the CreateInstance() method to create
-// an instance of you NaCl module on the web page. The browser creates a new
-// instance for each <embed> tag with type="application/x-nacl".
-class GetURLModule : public pp::Module {
+class URLLoaderModule : public pp::Module {
public:
- GetURLModule() : pp::Module() {}
- virtual ~GetURLModule() {}
+ URLLoaderModule() : pp::Module() {}
+ virtual ~URLLoaderModule() {}
- // Create and return a GetURLInstance object.
+ // Create and return a URLLoaderInstance object.
virtual pp::Instance* CreateInstance(PP_Instance instance) {
- return new GetURLInstance(instance);
+ return new URLLoaderInstance(instance);
}
};
-// Factory function called by the browser when the module is first loaded.
-// The browser keeps a singleton of this module. It calls the
-// CreateInstance() method on the object you return to make instances. There
-// is one instance per <embed> tag on the page. This is the main binding
-// point for your NaCl module with the browser.
namespace pp {
-Module* CreateModule() { return new GetURLModule(); }
+Module* CreateModule() { return new URLLoaderModule(); }
} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698