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

Side by Side Diff: shell/application_manager/local_fetcher.cc

Issue 1024723002: Add some trace points to mojo_shell for app lifetime (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "shell/application_manager/local_fetcher.h" 5 #include "shell/application_manager/local_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/trace_event/trace_event.h"
13 #include "mojo/common/common_type_converters.h" 14 #include "mojo/common/common_type_converters.h"
14 #include "mojo/common/data_pipe_utils.h" 15 #include "mojo/common/data_pipe_utils.h"
15 #include "url/url_util.h" 16 #include "url/url_util.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace shell { 19 namespace shell {
19 20
20 namespace { 21 namespace {
21 22
22 void IgnoreResult(bool result) { 23 void IgnoreResult(bool result) {
23 } 24 }
24 25
25 } // namespace 26 } // namespace
26 27
27 // A loader for local files. 28 // A loader for local files.
28 LocalFetcher::LocalFetcher(const GURL& url, 29 LocalFetcher::LocalFetcher(const GURL& url,
29 const GURL& url_without_query, 30 const GURL& url_without_query,
30 const FetchCallback& loader_callback) 31 const FetchCallback& loader_callback)
31 : Fetcher(loader_callback), url_(url), path_(UrlToFile(url_without_query)) { 32 : Fetcher(loader_callback), url_(url), path_(UrlToFile(url_without_query)) {
33 TRACE_EVENT0("mojo_shell", "LocalFetcher::LocalFetcher");
viettrungluu 2015/03/24 20:04:34 Should you record the url (with or without query,
jamesr 2015/03/27 20:42:21 Done.
32 loader_callback_.Run(make_scoped_ptr(this)); 34 loader_callback_.Run(make_scoped_ptr(this));
33 } 35 }
34 36
35 base::FilePath LocalFetcher::UrlToFile(const GURL& url) { 37 base::FilePath LocalFetcher::UrlToFile(const GURL& url) {
36 DCHECK(url.SchemeIsFile()); 38 DCHECK(url.SchemeIsFile());
37 url::RawCanonOutputW<1024> output; 39 url::RawCanonOutputW<1024> output;
38 url::DecodeURLEscapeSequences(url.path().data(), 40 url::DecodeURLEscapeSequences(url.path().data(),
39 static_cast<int>(url.path().length()), &output); 41 static_cast<int>(url.path().length()), &output);
40 base::string16 decoded_path = base::string16(output.data(), output.length()); 42 base::string16 decoded_path = base::string16(output.data(), output.length());
41 #if defined(OS_WIN) 43 #if defined(OS_WIN)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ReadFileToString(path_, &start_of_file, kMaxShebangLength); 97 ReadFileToString(path_, &start_of_file, kMaxShebangLength);
96 size_t return_position = start_of_file.find('\n'); 98 size_t return_position = start_of_file.find('\n');
97 if (return_position == std::string::npos) 99 if (return_position == std::string::npos)
98 return false; 100 return false;
99 *line = start_of_file.substr(0, return_position + 1); 101 *line = start_of_file.substr(0, return_position + 1);
100 return true; 102 return true;
101 } 103 }
102 104
103 } // namespace shell 105 } // namespace shell
104 } // namespace mojo 106 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698