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

Unified Diff: shell/application_manager/local_fetcher.cc

Issue 1088533003: Adding URLResponse Disk Cache to mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 5 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
« no previous file with comments | « shell/application_manager/application_manager.cc ('k') | shell/application_manager/native_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/application_manager/local_fetcher.cc
diff --git a/shell/application_manager/local_fetcher.cc b/shell/application_manager/local_fetcher.cc
index ad089132eb2a782d7cc29c5852f00496bd84424b..58d2a2dde0e53d57fe40e3723bc8cc7e96493c7d 100644
--- a/shell/application_manager/local_fetcher.cc
+++ b/shell/application_manager/local_fetcher.cc
@@ -5,6 +5,7 @@
#include "shell/application_manager/local_fetcher.h"
#include "base/bind.h"
+#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/message_loop/message_loop.h"
@@ -13,6 +14,7 @@
#include "base/trace_event/trace_event.h"
#include "mojo/common/common_type_converters.h"
#include "mojo/common/data_pipe_utils.h"
+#include <sys/stat.h>
#include "url/url_util.h"
namespace shell {
@@ -56,11 +58,14 @@ mojo::URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner,
response->url = mojo::String::From(url_);
mojo::DataPipe data_pipe;
response->body = data_pipe.consumer_handle.Pass();
- int64 file_size;
- if (base::GetFileSize(path_, &file_size)) {
- response->headers = mojo::Array<mojo::String>(1);
+ base::stat_wrapper_t stat_result;
+ if (stat64(path_.value().c_str(), &stat_result) == 0) {
+ response->headers = mojo::Array<mojo::String>(2);
response->headers[0] =
- base::StringPrintf("Content-Length: %" PRId64, file_size);
+ base::StringPrintf("Content-Length: %" PRId64, stat_result.st_size);
+ response->headers[1] = base::StringPrintf(
+ "ETag: \"%" PRId64 "-%" PRId64 "-%" PRId64 "\"", stat_result.st_dev,
+ stat_result.st_ino, static_cast<uint64_t>(stat_result.st_mtime));
}
mojo::common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip,
task_runner, base::Bind(&IgnoreResult));
« no previous file with comments | « shell/application_manager/application_manager.cc ('k') | shell/application_manager/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698