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

Side by Side Diff: extensions/renderer/i18n_custom_bindings.cc

Issue 2316093004: [Extensions] Add metrics for renderer sync IPCs performance (Closed)
Patch Set: Created 4 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 unified diff | Download patch
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 "extensions/renderer/i18n_custom_bindings.h" 5 #include "extensions/renderer/i18n_custom_bindings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h"
15 #include "content/public/child/v8_value_converter.h" 16 #include "content/public/child/v8_value_converter.h"
16 #include "content/public/renderer/render_frame.h" 17 #include "content/public/renderer/render_frame.h"
17 #include "content/public/renderer/render_thread.h" 18 #include "content/public/renderer/render_thread.h"
18 #include "extensions/common/extension_messages.h" 19 #include "extensions/common/extension_messages.h"
19 #include "extensions/common/message_bundle.h" 20 #include "extensions/common/message_bundle.h"
20 #include "extensions/renderer/script_context.h" 21 #include "extensions/renderer/script_context.h"
21 #include "extensions/renderer/v8_helpers.h" 22 #include "extensions/renderer/v8_helpers.h"
22 #include "third_party/cld/cld_version.h" 23 #include "third_party/cld/cld_version.h"
23 24
24 #if BUILDFLAG(CLD_VERSION) == 2 25 #if BUILDFLAG(CLD_VERSION) == 2
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 195 }
195 196
196 L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id); 197 L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id);
197 if (!l10n_messages) { 198 if (!l10n_messages) {
198 content::RenderFrame* render_frame = context()->GetRenderFrame(); 199 content::RenderFrame* render_frame = context()->GetRenderFrame();
199 if (!render_frame) 200 if (!render_frame)
200 return; 201 return;
201 202
202 L10nMessagesMap messages; 203 L10nMessagesMap messages;
203 // A sync call to load message catalogs for current extension. 204 // A sync call to load message catalogs for current extension.
204 render_frame->Send( 205 {
205 new ExtensionHostMsg_GetMessageBundle(extension_id, &messages)); 206 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.SyncGetMessageBundle");
207 render_frame->Send(
208 new ExtensionHostMsg_GetMessageBundle(extension_id, &messages));
209 }
206 210
207 // Save messages we got. 211 // Save messages we got.
208 ExtensionToL10nMessagesMap& l10n_messages_map = 212 ExtensionToL10nMessagesMap& l10n_messages_map =
209 *GetExtensionToL10nMessagesMap(); 213 *GetExtensionToL10nMessagesMap();
210 l10n_messages_map[extension_id] = messages; 214 l10n_messages_map[extension_id] = messages;
211 215
212 l10n_messages = GetL10nMessagesMap(extension_id); 216 l10n_messages = GetL10nMessagesMap(extension_id);
213 } 217 }
214 218
215 std::string message_name = *v8::String::Utf8Value(args[0]); 219 std::string message_name = *v8::String::Utf8Value(args[0]);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Populate LanguageDetectionResult with prediction reliability, languages, 302 // Populate LanguageDetectionResult with prediction reliability, languages,
299 // and the corresponding percentages. 303 // and the corresponding percentages.
300 InitDetectedLanguages(lang_results, &result); 304 InitDetectedLanguages(lang_results, &result);
301 args.GetReturnValue().Set(result.ToValue(context())); 305 args.GetReturnValue().Set(result.ToValue(context()));
302 #else 306 #else
303 # error "CLD_VERSION must be 2 or 3" 307 # error "CLD_VERSION must be 2 or 3"
304 #endif 308 #endif
305 } 309 }
306 310
307 } // namespace extensions 311 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698