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

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: Change to returning strings by value Created 8 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 | 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 std::string accepted_language_list = request_context->GetAcceptLanguage();
564 size_t separator = accepted_language_list.find_first_of(",;"); 564 size_t separator = accepted_language_list.find_first_of(",;");
565 if (separator != std::string::npos) 565 if (separator != std::string::npos)
566 langs = accepted_language_list.substr(0, separator); 566 langs = accepted_language_list.substr(0, separator);
567 } 567 }
568 if (langs.empty()) 568 if (langs.empty())
569 langs = "en-US"; 569 langs = "en-US";
570 return langs; 570 return langs;
571 } 571 }
572 572
573 // TODO(primiano): Is there any utility in the codebase that already does this? 573 // TODO(primiano): Is there any utility in the codebase that already does this?
574 std::string GoogleStreamingRemoteEngine::GenerateRequestKey() const { 574 std::string GoogleStreamingRemoteEngine::GenerateRequestKey() const {
575 const int64 kKeepLowBytes = GG_LONGLONG(0x00000000FFFFFFFF); 575 const int64 kKeepLowBytes = GG_LONGLONG(0x00000000FFFFFFFF);
576 const int64 kKeepHighBytes = GG_LONGLONG(0xFFFFFFFF00000000); 576 const int64 kKeepHighBytes = GG_LONGLONG(0xFFFFFFFF00000000);
577 577
578 // Just keep the least significant bits of timestamp, in order to reduce 578 // Just keep the least significant bits of timestamp, in order to reduce
579 // probability of collisions. 579 // probability of collisions.
580 int64 key = (base::Time::Now().ToInternalValue() & kKeepLowBytes) | 580 int64 key = (base::Time::Now().ToInternalValue() & kKeepLowBytes) |
581 (base::RandUint64() & kKeepHighBytes); 581 (base::RandUint64() & kKeepHighBytes);
582 return base::HexEncode(reinterpret_cast<void*>(&key), sizeof(key)); 582 return base::HexEncode(reinterpret_cast<void*>(&key), sizeof(key));
583 } 583 }
584 584
585 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) 585 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value)
586 : event(event_value) { 586 : event(event_value) {
587 } 587 }
588 588
589 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { 589 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() {
590 } 590 }
591 591
592 } // namespace speech 592 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698