Skip to content

Commit

Permalink
Bug 1249389 - part 7 - clean up calls to GetBuffer in TestStartupCach…
Browse files Browse the repository at this point in the history
…e; r=erahm

With the previous patch, we're able to eliminate some raw pointer usages
in TestStartupCache, which is always nice.
  • Loading branch information
froydnj committed Feb 18, 2016
1 parent 753d510 commit 48d5ece
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions startupcache/test/TestStartupCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ TestWriteInvalidateRead() {
nsresult rv;
const char* buf = "BeardBook competitive analysis";
const char* id = "id";
char* outbuf = nullptr;
UniquePtr<char[]> outbuf;
uint32_t len;
nsCOMPtr<nsIStartupCache> sc
= do_GetService("@mozilla.org/startupcache/cache;1", &rv);
Expand All @@ -130,7 +130,6 @@ TestWriteInvalidateRead() {
sc->InvalidateCache();

rv = sc->GetBuffer(id, &outbuf, &len);
delete[] outbuf;
if (rv == NS_ERROR_NOT_AVAILABLE) {
passed("buffer not available after invalidate");
} else if (NS_SUCCEEDED(rv)) {
Expand Down Expand Up @@ -206,16 +205,16 @@ TestWriteObject() {
return rv;
}

nsAutoArrayPtr<char> buf2;
UniquePtr<char[]> buf2;
uint32_t len2;
nsCOMPtr<nsIObjectInputStream> objectInput;
rv = sc->GetBuffer(id, getter_Transfers(buf2), &len2);
rv = sc->GetBuffer(id, &buf2, &len2);
if (NS_FAILED(rv)) {
fail("failed to retrieve buffer");
return rv;
}

rv = NewObjectInputStreamFromBuffer(UniquePtr<char[]>(buf2.forget()), len2,
rv = NewObjectInputStreamFromBuffer(Move(buf2), len2,
getter_AddRefs(objectInput));
if (NS_FAILED(rv)) {
fail("failed to created input stream");
Expand Down Expand Up @@ -309,7 +308,7 @@ TestIgnoreDiskCache(nsIFile* profileDir) {

const char* buf = "Get a Beardbook app for your smartphone";
const char* id = "id";
char* outbuf = nullptr;
UniquePtr<char[]> outbuf;
uint32_t len;

rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
Expand All @@ -329,8 +328,6 @@ TestIgnoreDiskCache(nsIFile* profileDir) {
nsresult r = LockCacheFile(false, profileDir);
NS_ENSURE_SUCCESS(r, r);

delete[] outbuf;

if (rv == NS_ERROR_NOT_AVAILABLE) {
passed("buffer not available after ignoring disk cache");
} else if (NS_SUCCEEDED(rv)) {
Expand All @@ -355,7 +352,7 @@ TestEarlyShutdown() {
const char* buf = "Find your soul beardmate on BeardBook";
const char* id = "id";
uint32_t len;
char* outbuf = nullptr;
UniquePtr<char[]> outbuf;

sc->ResetStartupWriteTimer();
rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
Expand All @@ -368,7 +365,6 @@ TestEarlyShutdown() {
NS_ENSURE_SUCCESS(rv, rv);

rv = sc->GetBuffer(id, &outbuf, &len);
delete[] outbuf;

if (NS_SUCCEEDED(rv)) {
passed("GetBuffer succeeded after early shutdown");
Expand Down

0 comments on commit 48d5ece

Please sign in to comment.