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

Side by Side Diff: content/renderer/manifest/manifest_manager.cc

Issue 622813002: [Manifest] Add metrics recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_orientation_usage_count
Patch Set: Created 6 years, 2 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/manifest/manifest_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/manifest/manifest_manager.h" 5 #include "content/renderer/manifest/manifest_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "content/common/manifest_manager_messages.h" 9 #include "content/common/manifest_manager_messages.h"
10 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
11 #include "content/renderer/fetchers/manifest_fetcher.h" 11 #include "content/renderer/fetchers/manifest_fetcher.h"
12 #include "content/renderer/manifest/manifest_parser.h" 12 #include "content/renderer/manifest/manifest_parser.h"
13 #include "content/renderer/manifest/manifest_uma_util.h"
13 #include "third_party/WebKit/public/platform/WebURLResponse.h" 14 #include "third_party/WebKit/public/platform/WebURLResponse.h"
14 #include "third_party/WebKit/public/web/WebDocument.h" 15 #include "third_party/WebKit/public/web/WebDocument.h"
15 #include "third_party/WebKit/public/web/WebLocalFrame.h" 16 #include "third_party/WebKit/public/web/WebLocalFrame.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 ManifestManager::ManifestManager(RenderFrame* render_frame) 20 ManifestManager::ManifestManager(RenderFrame* render_frame)
20 : RenderFrameObserver(render_frame), 21 : RenderFrameObserver(render_frame),
21 may_have_manifest_(false), 22 may_have_manifest_(false),
22 manifest_dirty_(true) { 23 manifest_dirty_(true) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 void ManifestManager::DidChangeManifest() { 98 void ManifestManager::DidChangeManifest() {
98 may_have_manifest_ = true; 99 may_have_manifest_ = true;
99 manifest_dirty_ = true; 100 manifest_dirty_ = true;
100 } 101 }
101 102
102 void ManifestManager::FetchManifest() { 103 void ManifestManager::FetchManifest() {
103 GURL url(render_frame()->GetWebFrame()->document().manifestURL()); 104 GURL url(render_frame()->GetWebFrame()->document().manifestURL());
104 105
105 if (url.is_empty()) { 106 if (url.is_empty()) {
107 ManifestUmaUtil::FetchFailed(ManifestUmaUtil::FETCH_EMPTY_URL);
106 ResolveCallbacks(ResolveStateFailure); 108 ResolveCallbacks(ResolveStateFailure);
107 return; 109 return;
108 } 110 }
109 111
110 fetcher_.reset(new ManifestFetcher(url)); 112 fetcher_.reset(new ManifestFetcher(url));
111 113
112 // TODO(mlamouri,kenneth): this is not yet taking into account manifest-src 114 // TODO(mlamouri,kenneth): this is not yet taking into account manifest-src
113 // CSP rule, see http://crbug.com/409996. 115 // CSP rule, see http://crbug.com/409996.
114 fetcher_->Start(render_frame()->GetWebFrame(), 116 fetcher_->Start(render_frame()->GetWebFrame(),
115 base::Bind(&ManifestManager::OnManifestFetchComplete, 117 base::Bind(&ManifestManager::OnManifestFetchComplete,
116 base::Unretained(this), 118 base::Unretained(this),
117 render_frame()->GetWebFrame()->document().url())); 119 render_frame()->GetWebFrame()->document().url()));
118 } 120 }
119 121
120 void ManifestManager::OnManifestFetchComplete( 122 void ManifestManager::OnManifestFetchComplete(
121 const GURL& document_url, 123 const GURL& document_url,
122 const blink::WebURLResponse& response, 124 const blink::WebURLResponse& response,
123 const std::string& data) { 125 const std::string& data) {
124 if (response.isNull() && data.empty()) { 126 if (response.isNull() && data.empty()) {
127 ManifestUmaUtil::FetchFailed(ManifestUmaUtil::FETCH_UNSPECIFIED_REASON);
125 ResolveCallbacks(ResolveStateFailure); 128 ResolveCallbacks(ResolveStateFailure);
126 return; 129 return;
127 } 130 }
128 131
132 ManifestUmaUtil::FetchSucceeded();
129 manifest_ = ManifestParser::Parse(data, response.url(), document_url); 133 manifest_ = ManifestParser::Parse(data, response.url(), document_url);
130 134
131 fetcher_.reset(); 135 fetcher_.reset();
132 ResolveCallbacks(ResolveStateSuccess); 136 ResolveCallbacks(ResolveStateSuccess);
133 } 137 }
134 138
135 void ManifestManager::ResolveCallbacks(ResolveState state) { 139 void ManifestManager::ResolveCallbacks(ResolveState state) {
136 if (state == ResolveStateFailure) 140 if (state == ResolveStateFailure)
137 manifest_ = Manifest(); 141 manifest_ = Manifest();
138 142
139 manifest_dirty_ = state != ResolveStateSuccess; 143 manifest_dirty_ = state != ResolveStateSuccess;
140 144
141 Manifest manifest = manifest_; 145 Manifest manifest = manifest_;
142 std::list<GetManifestCallback> callbacks = pending_callbacks_; 146 std::list<GetManifestCallback> callbacks = pending_callbacks_;
143 147
144 pending_callbacks_.clear(); 148 pending_callbacks_.clear();
145 149
146 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); 150 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin();
147 it != callbacks.end(); ++it) { 151 it != callbacks.end(); ++it) {
148 it->Run(manifest); 152 it->Run(manifest);
149 } 153 }
150 } 154 }
151 155
152 } // namespace content 156 } // namespace content
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/manifest/manifest_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698