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

Side by Side Diff: content/browser/speech/google_streaming_remote_engine.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for chrome_frame_net_tests Created 8 years, 1 month 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 | Annotate | Revision Log
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 "content/browser/speech/google_streaming_remote_engine.h" 5 #include "content/browser/speech/google_streaming_remote_engine.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 553
554 std::string GoogleStreamingRemoteEngine::GetAcceptedLanguages() const { 554 std::string GoogleStreamingRemoteEngine::GetAcceptedLanguages() const {
555 std::string langs = config_.language; 555 std::string langs = config_.language;
556 if (langs.empty() && url_context_) { 556 if (langs.empty() && url_context_) {
557 // If no language is provided then we use the first from the accepted 557 // If no language is provided then we use the first from the accepted
558 // language list. If this list is empty then it defaults to "en-US". 558 // language list. If this list is empty then it defaults to "en-US".
559 // Example of the contents of this list: "es,en-GB;q=0.8", "" 559 // Example of the contents of this list: "es,en-GB;q=0.8", ""
560 net::URLRequestContext* request_context = 560 net::URLRequestContext* request_context =
561 url_context_->GetURLRequestContext(); 561 url_context_->GetURLRequestContext();
562 DCHECK(request_context); 562 DCHECK(request_context);
563 std::string accepted_language_list = request_context->accept_language(); 563 // TODO(pauljensen): GoogleStreamingRemoteEngine should be constructed with
564 // a reference to the HttpUserAgentSettings rather than accessing the
565 // accept language through the URLRequestContext.
566 std::string accepted_language_list = request_context->GetAcceptLanguage();
564 size_t separator = accepted_language_list.find_first_of(",;"); 567 size_t separator = accepted_language_list.find_first_of(",;");
565 if (separator != std::string::npos) 568 if (separator != std::string::npos)
566 langs = accepted_language_list.substr(0, separator); 569 langs = accepted_language_list.substr(0, separator);
567 } 570 }
568 if (langs.empty()) 571 if (langs.empty())
569 langs = "en-US"; 572 langs = "en-US";
570 return langs; 573 return langs;
571 } 574 }
572 575
573 // TODO(primiano): Is there any utility in the codebase that already does this? 576 // TODO(primiano): Is there any utility in the codebase that already does this?
574 std::string GoogleStreamingRemoteEngine::GenerateRequestKey() const { 577 std::string GoogleStreamingRemoteEngine::GenerateRequestKey() const {
575 const int64 kKeepLowBytes = GG_LONGLONG(0x00000000FFFFFFFF); 578 const int64 kKeepLowBytes = GG_LONGLONG(0x00000000FFFFFFFF);
576 const int64 kKeepHighBytes = GG_LONGLONG(0xFFFFFFFF00000000); 579 const int64 kKeepHighBytes = GG_LONGLONG(0xFFFFFFFF00000000);
577 580
578 // Just keep the least significant bits of timestamp, in order to reduce 581 // Just keep the least significant bits of timestamp, in order to reduce
579 // probability of collisions. 582 // probability of collisions.
580 int64 key = (base::Time::Now().ToInternalValue() & kKeepLowBytes) | 583 int64 key = (base::Time::Now().ToInternalValue() & kKeepLowBytes) |
581 (base::RandUint64() & kKeepHighBytes); 584 (base::RandUint64() & kKeepHighBytes);
582 return base::HexEncode(reinterpret_cast<void*>(&key), sizeof(key)); 585 return base::HexEncode(reinterpret_cast<void*>(&key), sizeof(key));
583 } 586 }
584 587
585 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) 588 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value)
586 : event(event_value) { 589 : event(event_value) {
587 } 590 }
588 591
589 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { 592 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() {
590 } 593 }
591 594
592 } // namespace content 595 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/google_one_shot_remote_engine.cc ('k') | content/shell/shell_url_request_context_getter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698