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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Fix calling Init function in sync_client.cc 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/spellchecker/spelling_service_client.h" 5 #include "chrome/browser/spellchecker/spelling_service_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "chrome/common/spellcheck_common.h" 19 #include "chrome/common/spellcheck_common.h"
20 #include "chrome/common/spellcheck_result.h" 20 #include "chrome/common/spellcheck_result.h"
21 #include "components/data_use_measurement/core/data_use_user_data.h"
21 #include "components/user_prefs/user_prefs.h" 22 #include "components/user_prefs/user_prefs.h"
22 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
23 #include "google_apis/google_api_keys.h" 24 #include "google_apis/google_api_keys.h"
24 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
25 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace { 29 namespace {
29 30
30 // The URL for requesting spell checking and sending user feedback. 31 // The URL for requesting spell checking and sending user feedback.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 std::string request = base::StringPrintf( 99 std::string request = base::StringPrintf(
99 kSpellingRequest, 100 kSpellingRequest,
100 type, 101 type,
101 encoded_text.c_str(), 102 encoded_text.c_str(),
102 language_code.c_str(), 103 language_code.c_str(),
103 country_code.c_str(), 104 country_code.c_str(),
104 api_key.c_str()); 105 api_key.c_str());
105 106
106 GURL url = GURL(kSpellingServiceURL); 107 GURL url = GURL(kSpellingServiceURL);
107 net::URLFetcher* fetcher = CreateURLFetcher(url).release(); 108 net::URLFetcher* fetcher = CreateURLFetcher(url).release();
109 data_use_measurement::DataUseUserData::AttachToFetcher(
110 fetcher, data_use_measurement::DataUseUserData::SPELL_CHECKER);
108 fetcher->SetRequestContext(context->GetRequestContext()); 111 fetcher->SetRequestContext(context->GetRequestContext());
109 fetcher->SetUploadData("application/json", request); 112 fetcher->SetUploadData("application/json", request);
110 fetcher->SetLoadFlags( 113 fetcher->SetLoadFlags(
111 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 114 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
112 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text); 115 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text);
113 fetcher->Start(); 116 fetcher->Start();
114 return true; 117 return true;
115 } 118 }
116 119
117 bool SpellingServiceClient::IsAvailable( 120 bool SpellingServiceClient::IsAvailable(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 267
265 // The callback may release the last (transitive) dependency on |this|. It 268 // The callback may release the last (transitive) dependency on |this|. It
266 // MUST be the last function called. 269 // MUST be the last function called.
267 callback_data->callback.Run(success, callback_data->text, results); 270 callback_data->callback.Run(success, callback_data->text, results);
268 } 271 }
269 272
270 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( 273 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher(
271 const GURL& url) { 274 const GURL& url) {
272 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); 275 return net::URLFetcher::Create(url, net::URLFetcher::POST, this);
273 } 276 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc ('k') | chrome/browser/sync/glue/sync_backend_host_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698