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

Unified Diff: shell/application_manager/fetcher.cc

Issue 1276073004: Offline By Default (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add missing explicits. Created 5 years, 3 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 | « shell/application_manager/fetcher.h ('k') | shell/application_manager/local_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/application_manager/fetcher.cc
diff --git a/shell/application_manager/fetcher.cc b/shell/application_manager/fetcher.cc
index f76876bac3e7f5b70ba5ca71f0e6cfb810e22602..539cb64ebd9f247f46f62fa888d239971c55e13b 100644
--- a/shell/application_manager/fetcher.cc
+++ b/shell/application_manager/fetcher.cc
@@ -4,12 +4,16 @@
#include "shell/application_manager/fetcher.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "url/gurl.h"
namespace shell {
-const char Fetcher::kMojoMagic[] = "#!mojo ";
-const size_t Fetcher::kMaxShebangLength = 2048;
+namespace {
+const char kMojoMagic[] = "#!mojo ";
+const size_t kMaxShebangLength = 2048;
+}
Fetcher::Fetcher(const FetchCallback& loader_callback)
: loader_callback_(loader_callback) {
@@ -33,4 +37,24 @@ bool Fetcher::PeekContentHandler(std::string* mojo_shebang,
return false;
}
+// static
+bool Fetcher::HasMojoMagic(const base::FilePath& path) {
+ DCHECK(!path.empty());
+ std::string magic;
+ ReadFileToString(path, &magic, strlen(kMojoMagic));
+ return magic == kMojoMagic;
+}
+
+// static
+bool Fetcher::PeekFirstLine(const base::FilePath& path, std::string* line) {
+ DCHECK(!path.empty());
+ std::string start_of_file;
+ ReadFileToString(path, &start_of_file, kMaxShebangLength);
+ size_t return_position = start_of_file.find('\n');
+ if (return_position == std::string::npos)
+ return false;
+ *line = start_of_file.substr(0, return_position + 1);
+ return true;
+}
+
} // namespace shell
« no previous file with comments | « shell/application_manager/fetcher.h ('k') | shell/application_manager/local_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698