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


C++ WebHistoryItem::ref方法代码示例

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


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

示例1: WebHistoryInflate

static jint WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray data)
{
    ALOG_ASSERT(frame, "Inflate needs a valid frame pointer!");
    ALOG_ASSERT(data, "Inflate needs a valid data pointer!");

    // Get the actual bytes and the length from the java array.
    const jbyte* bytes = env->GetByteArrayElements(data, NULL);
    jsize size = env->GetArrayLength(data);

    // Inflate the history tree into one HistoryItem or null if the inflation
    // failed.
    RefPtr<WebCore::HistoryItem> newItem = WebCore::HistoryItem::create();
    WebHistoryItem* bridge = new WebHistoryItem(newItem.get());
    newItem->setBridge(bridge);

    // Inflate the item recursively. If it fails, that is ok. We'll have an
    // incomplete HistoryItem but that is better than crashing due to a null
    // item.
    // We have a 2nd local variable since read_item_recursive may change the
    // ptr's value. We can't pass &bytes since we have to send bytes to
    // ReleaseByteArrayElements unchanged.
    const char* ptr = reinterpret_cast<const char*>(bytes);
    readItemRecursive(newItem.get(), &ptr, (int)size);
    env->ReleaseByteArrayElements(data, const_cast<jbyte*>(bytes), JNI_ABORT);
    bridge->setActive();

    // Add the new item to the back/forward list.
    WebCore::Frame* pFrame = (WebCore::Frame*)frame;
    pFrame->page()->backForwardList()->addItem(newItem);

    // Update the item.
    bridge->updateHistoryItem(newItem.get());
    // Ref here because Java expects to adopt the reference, and as such will not
    // call ref on it. However, setBridge has also adopted the reference
    // TODO: This is confusing as hell, clean up ownership and have setBridge
    // take a RefPtr instead of a raw ptr and calling adoptRef on it
    bridge->ref();
    return reinterpret_cast<jint>(bridge);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:39,代码来源:WebHistory.cpp


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