当前位置: 首页>>代码示例>>C++>>正文


C++ String::threadsafeCopy方法代码示例

本文整理汇总了C++中wtf::String::threadsafeCopy方法的典型用法代码示例。如果您正苦于以下问题:C++ String::threadsafeCopy方法的具体用法?C++ String::threadsafeCopy怎么用?C++ String::threadsafeCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wtf::String的用法示例。


在下文中一共展示了String::threadsafeCopy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateHistoryItem

void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) {
    // Do not want to update during inflation.
    if (!m_active)
        return;
    WebHistoryItem* webItem = this;
    // Now we need to update the top-most WebHistoryItem based on the top-most
    // HistoryItem.
    if (m_parent) {
        webItem = m_parent.get();
        if (webItem->hasOneRef()) {
            // if the parent only has one ref, it is from this WebHistoryItem.
            // This means that the matching WebCore::HistoryItem has been freed.
            // This can happen during clear().
            ALOGW("Can't updateHistoryItem as the top HistoryItem is gone");
            return;
        }
        while (webItem->parent())
            webItem = webItem->parent();
        item = webItem->historyItem();
        if (!item) {
            // If a HistoryItem only exists for page cache, it is possible that
            // the parent HistoryItem destroyed before the child HistoryItem. If
            // it happens, skip updating.
            ALOGW("Can't updateHistoryItem as the top HistoryItem is gone");
            return;
        }
    }
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    if (!env)
        return;

    MutexLocker locker(webItem->m_lock);

    // TODO: Figure out if we can't just use item->urlString() instead...
    const WTF::String urlString = WebFrame::convertIDNToUnicode(item->url());
    webItem->m_url = urlString.threadsafeCopy();
    const WTF::String originalUrlString = WebFrame::convertIDNToUnicode(item->originalURL());
    webItem->m_originalUrl = originalUrlString.threadsafeCopy();
    const WTF::String& titleString = item->title();
    webItem->m_title = titleString.threadsafeCopy();

    // Try to get the favicon from the history item. For some pages like Grand
    // Prix, there are history items with anchors. If the icon fails for the
    // item, try to get the icon using the url without the ref.
    jobject favicon = NULL;
    WTF::String url = item->urlString();
    if (item->url().hasFragmentIdentifier()) {
        int refIndex = url.reverseFind('#');
        url = url.substring(0, refIndex);
    }
    // FIXME: This method should not be used from outside WebCore and will be removed.
    // http://trac.webkit.org/changeset/81484
    WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(url, WebCore::IntSize(16, 16));
    delete webItem->m_favicon;
    webItem->m_favicon = webcoreImageToSkBitmap(icon);
    if (webItem->m_faviconCached) {
        env->DeleteGlobalRef(webItem->m_faviconCached);
        webItem->m_faviconCached = 0;
    }

    webItem->m_data.clear();
    WebHistory::Flatten(env, webItem->m_data, item);
    if (webItem->m_dataCached) {
        env->DeleteGlobalRef(webItem->m_dataCached);
        webItem->m_dataCached = 0;
    }
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:67,代码来源:WebHistory.cpp


注:本文中的wtf::String::threadsafeCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。