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

Unified Diff: chrome/renderer/about_handler.cc

Issue 2814012: Split part of about_handler into chrome/common to break the browser-renderer ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: with unit test Created 10 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
« no previous file with comments | « chrome/renderer/about_handler.h ('k') | chrome/renderer/renderer_about_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/about_handler.cc
===================================================================
--- chrome/renderer/about_handler.cc (revision 50056)
+++ chrome/renderer/about_handler.cc (working copy)
@@ -5,48 +5,33 @@
#include "chrome/renderer/about_handler.h"
#include "base/platform_thread.h"
-#include "chrome/common/url_constants.h"
-#include "googleurl/src/gurl.h"
+#include "chrome/common/about_handler.h"
-struct AboutHandlerUrl {
- const char *url;
- void (*action)();
-};
+typedef void (*AboutHandlerFuncPtr)();
-static AboutHandlerUrl about_urls[] = {
- { chrome::kAboutCrashURL, AboutHandler::AboutCrash },
- { chrome::kAboutHangURL, AboutHandler::AboutHang },
- { chrome::kAboutShorthangURL, AboutHandler::AboutShortHang },
- { NULL, NULL }
+// This needs to match up with chrome_about_handler::about_urls in
+// chrome/common/about_handler.cc.
+static const AboutHandlerFuncPtr about_urls_handlers[] = {
+ AboutHandler::AboutCrash,
+ AboutHandler::AboutHang,
+ AboutHandler::AboutShortHang,
+ NULL,
};
-static const char* kAboutScheme = "about";
-
-bool AboutHandler::WillHandle(const GURL& url) {
- if (url.scheme() != kAboutScheme)
- return false;
-
- struct AboutHandlerUrl* url_handler = about_urls;
- while (url_handler->url) {
- if (url == GURL(url_handler->url))
- return true;
- url_handler++;
- }
- return false;
-}
-
// static
bool AboutHandler::MaybeHandle(const GURL& url) {
- if (url.scheme() != kAboutScheme)
+ if (url.scheme() != chrome_about_handler::kAboutScheme)
return false;
- struct AboutHandlerUrl* url_handler = about_urls;
- while (url_handler->url) {
- if (url == GURL(url_handler->url)) {
- url_handler->action();
+ int about_urls_handler_index = 0;
+ const char* const* url_handler = chrome_about_handler::about_urls;
+ while (*url_handler) {
+ if (GURL(*url_handler) == url) {
+ about_urls_handlers[about_urls_handler_index]();
return true; // theoretically :]
}
url_handler++;
+ about_urls_handler_index++;
}
return false;
}
@@ -68,3 +53,8 @@
void AboutHandler::AboutShortHang() {
PlatformThread::Sleep(20000);
}
+
+// static
+size_t AboutHandler::AboutURLHandlerSize() {
+ return arraysize(about_urls_handlers);
+}
« no previous file with comments | « chrome/renderer/about_handler.h ('k') | chrome/renderer/renderer_about_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698