gfx/skia/trunk/src/utils/mac/SkStream_mac.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /*
     2  * Copyright 2012 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #include "SkCGUtils.h"
     9 #include "SkStream.h"
    11 // This is used by CGDataProviderCreateWithData
    13 static void unref_proc(void* info, const void* addr, size_t size) {
    14     SkASSERT(info);
    15     ((SkRefCnt*)info)->unref();
    16 }
    18 // These are used by CGDataProviderSequentialCallbacks
    20 static size_t get_bytes_proc(void* info, void* buffer, size_t bytes) {
    21     SkASSERT(info);
    22     return ((SkStream*)info)->read(buffer, bytes);
    23 }
    25 static off_t skip_forward_proc(void* info, off_t bytes) {
    26     return ((SkStream*)info)->skip((size_t) bytes);
    27 }
    29 static void rewind_proc(void* info) {
    30     SkASSERT(info);
    31     ((SkStream*)info)->rewind();
    32 }
    34 static void release_info_proc(void* info) {
    35     SkASSERT(info);
    36     ((SkStream*)info)->unref();
    37 }
    39 CGDataProviderRef SkCreateDataProviderFromStream(SkStream* stream) {
    40     stream->ref();  // unref will be called when the provider is deleted
    42     const void* addr = stream->getMemoryBase();
    43     if (addr) {
    44         // special-case when the stream is just a block of ram
    45         return CGDataProviderCreateWithData(stream, addr, stream->getLength(),
    46                                             unref_proc);
    47     }
    49     CGDataProviderSequentialCallbacks rec;
    50     sk_bzero(&rec, sizeof(rec));
    51     rec.version = 0;
    52     rec.getBytes = get_bytes_proc;
    53     rec.skipForward = skip_forward_proc;
    54     rec.rewind = rewind_proc;
    55     rec.releaseInfo = release_info_proc;
    56     return CGDataProviderCreateSequential(stream, &rec);
    57 }
    59 ///////////////////////////////////////////////////////////////////////////////
    61 #include "SkData.h"
    63 CGDataProviderRef SkCreateDataProviderFromData(SkData* data) {
    64     data->ref();
    65     return CGDataProviderCreateWithData(data, data->data(), data->size(),
    66                                             unref_proc);
    67 }

mercurial