mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1190252. Backed out changeset d697030f7d59. r=backout
This commit is contained in:
parent
751d662f3d
commit
c32f098f77
@ -19,7 +19,7 @@
|
||||
#include "gmp-video-encode.h"
|
||||
#include "GMPPlatform.h"
|
||||
#include "mozilla/dom/CrashReporterChild.h"
|
||||
#include "GMPUtils.h"
|
||||
#include "mozilla/Tokenizer.h"
|
||||
#include "prio.h"
|
||||
|
||||
using mozilla::dom::CrashReporterChild;
|
||||
@ -341,6 +341,24 @@ ReadIntoString(nsIFile* aFile,
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsTArray<nsCString>
|
||||
SplitAt(Tokenizer::Token aDelim, const nsACString& aInput)
|
||||
{
|
||||
nsTArray<nsCString> tokens;
|
||||
Tokenizer tokenizer(aInput);
|
||||
|
||||
while (!tokenizer.HasFailed()) {
|
||||
tokenizer.Record();
|
||||
Tokenizer::Token token;
|
||||
while (tokenizer.Next(token) && !token.Equals(aDelim))
|
||||
; // Skip up to next delimeter, or EOF.
|
||||
nsAutoCString value;
|
||||
tokenizer.Claim(value);
|
||||
tokens.AppendElement(value);
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
// Pre-load DLLs that need to be used by the EME plugin but that can't be
|
||||
// loaded after the sandbox has started
|
||||
bool
|
||||
@ -369,9 +387,7 @@ GMPChild::PreLoadLibraries(const nsAString& aPluginPath)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note: we pass "\r\n" to SplitAt so that we'll split lines delimited
|
||||
// by \n (Unix), \r\n (Windows) and \r (old MacOSX).
|
||||
nsTArray<nsCString> lines = SplitAt("\r\n", info);
|
||||
nsTArray<nsCString> lines = SplitAt(Tokenizer::Token::NewLine(), info);
|
||||
for (nsCString line : lines) {
|
||||
// Make lowercase.
|
||||
std::transform(line.BeginWriting(),
|
||||
@ -385,8 +401,8 @@ GMPChild::PreLoadLibraries(const nsAString& aPluginPath)
|
||||
continue;
|
||||
}
|
||||
// Line starts with "libraries:".
|
||||
nsTArray<nsCString> libs =
|
||||
SplitAt(",", Substring(line, offset + strlen(libraries)));
|
||||
nsTArray<nsCString> libs = SplitAt(Tokenizer::Token::Char(','),
|
||||
Substring(line, offset + strlen(libraries)));
|
||||
for (nsCString lib : libs) {
|
||||
lib.Trim(" ");
|
||||
for (const char* whiteListedLib : whitelist) {
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "nsIFile.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -38,17 +36,4 @@ EMEVoucherFileExists()
|
||||
exists;
|
||||
}
|
||||
|
||||
nsTArray<nsCString>
|
||||
SplitAt(const char* aDelims, const nsACString& aInput)
|
||||
{
|
||||
nsTArray<nsCString> tokens;
|
||||
nsAutoCString str(aInput);
|
||||
char* end = str.BeginWriting();
|
||||
const char* start = nullptr;
|
||||
while (!!(start = NS_strtok(aDelims, &end))) {
|
||||
tokens.AppendElement(nsCString(start));
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -27,9 +27,6 @@ bool GetEMEVoucherPath(nsIFile** aPath);
|
||||
|
||||
bool EMEVoucherFileExists();
|
||||
|
||||
nsTArray<nsCString>
|
||||
SplitAt(const char* aDelims, const nsACString& aInput);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
|
@ -1,53 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "GMPUtils.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace mozilla;
|
||||
|
||||
struct SplitAtTest {
|
||||
string mInput;
|
||||
const char* mDelims;
|
||||
vector<string> mTokens;
|
||||
};
|
||||
|
||||
static const SplitAtTest sSplitAtTests[] {
|
||||
{
|
||||
"1,2,3,4",
|
||||
",",
|
||||
{ "1", "2", "3", "4" },
|
||||
}, {
|
||||
"a simple, comma, seperated, list",
|
||||
",",
|
||||
{"a simple", " comma", " seperated", " list"},
|
||||
}, {
|
||||
// Various platform line endings...
|
||||
"line1\r\n" // Windows
|
||||
"line2\r" // Old MacOSX
|
||||
"line3\n" // Unix
|
||||
"line4",
|
||||
"\r\n",
|
||||
{ "line1", "line2", "line3", "line4" },
|
||||
},
|
||||
};
|
||||
|
||||
TEST(GeckoMediaPlugins, GMPUtils) {
|
||||
for (const SplitAtTest& test : sSplitAtTests) {
|
||||
nsCString input(test.mInput.c_str(), test.mInput.size());
|
||||
nsTArray<nsCString> tokens = SplitAt(test.mDelims, input);
|
||||
EXPECT_EQ(tokens.Length(), test.mTokens.size()) << "Should get expected number of tokens";
|
||||
for (size_t i = 0; i < tokens.Length(); i++) {
|
||||
EXPECT_TRUE(tokens[i].EqualsASCII(test.mTokens[i].c_str()))
|
||||
<< "Tokenize fail; expected=" << test.mTokens[i] << " got=" <<
|
||||
tokens[i].BeginReading();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ UNIFIED_SOURCES += [
|
||||
'TestAudioCompactor.cpp',
|
||||
'TestGMPCrossOrigin.cpp',
|
||||
'TestGMPRemoveAndDelete.cpp',
|
||||
'TestGMPUtils.cpp',
|
||||
'TestIntervalSet.cpp',
|
||||
'TestMediaEventSource.cpp',
|
||||
'TestMozPromise.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user